PandaTech.StartupEnvironmentCheck 2.0.0

dotnet add package PandaTech.StartupEnvironmentCheck --version 2.0.0
NuGet\Install-Package PandaTech.StartupEnvironmentCheck -Version 2.0.0
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="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PandaTech.StartupEnvironmentCheck --version 2.0.0
#r "nuget: PandaTech.StartupEnvironmentCheck, 2.0.0"
#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=2.0.0

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

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 net8.0 is compatible.  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.
  • net8.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
2.0.0 232 11/29/2023
1.0.5 101 11/29/2023
1.0.4 180 10/14/2023
1.0.3 127 10/14/2023
1.0.2 160 8/30/2023
1.0.1 156 8/24/2023
1.0.0 143 8/23/2023

.net 8 update