PandaTech.StartupEnvironmentCheck 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package PandaTech.StartupEnvironmentCheck --version 1.0.1                
NuGet\Install-Package PandaTech.StartupEnvironmentCheck -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PandaTech.StartupEnvironmentCheck" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PandaTech.StartupEnvironmentCheck --version 1.0.1                
#r "nuget: PandaTech.StartupEnvironmentCheck, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PandaTech.StartupEnvironmentCheck as a Cake Addin
#addin nuget:?package=PandaTech.StartupEnvironmentCheck&version=1.0.1

// Install PandaTech.StartupEnvironmentCheck as a Cake Tool
#tool nuget:?package=PandaTech.StartupEnvironmentCheck&version=1.0.1                

Pandatech.StartupEnvironmentCheck

Pandatech.StartupEnvironmentCheck is a lightweight library designed to validate required environment variables at application startup. It helps ensure that essential configurations are in place, preventing unexpected behaviors or failures due to missing environment variables.

Installation

You can install Pandatech.StartupEnvironmentCheck via NuGet Package Manager or by using the following command in your Package Manager Console:

Install-Package Pandatech.StartupEnvironmentCheck

Usage

Validating Environment Variables

You can use the EnvironmentVariableValidator.ValidateEnvironmentVariables method to validate required environment variables. Here's an example:

using StartupEnvironmentCheck;

public class Program
{
    public static void Main(string[] args)
    {
        var requiredEnvVars = new List<string> { "DB_CONNECTION_STRING", "API_KEY" };
        EnvironmentVariableValidator.ValidateEnvironmentVariables(requiredEnvVars);
        
        // Continue with the rest of the application startup
    }
}

Handling Missing Variables

If any required environment variables are missing, a MissingEnvironmentVariablesException will be thrown. This exception includes a detailed message listing the missing variables.

You can catch this exception to log the error or take other appropriate actions:

try
{
EnvironmentVariableValidator.ValidateEnvironmentVariables(requiredEnvVars);
}
catch (MissingEnvironmentVariablesException ex)
{
// Log the error or take other actions
}

Contributing

For support, issues, or contributions, please refer to the project's GitHub repository or contact the maintainers.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 216 10/14/2023
1.0.3 160 10/14/2023
1.0.2 192 8/30/2023
1.0.1 182 8/24/2023
1.0.0 173 8/23/2023

Exception message refactored to become more visible and readable.