PandaTech.StartupEnvironmentCheck
1.0.1
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
<PackageReference Include="PandaTech.StartupEnvironmentCheck" Version="1.0.1" />
paket add PandaTech.StartupEnvironmentCheck --version 1.0.1
#r "nuget: PandaTech.StartupEnvironmentCheck, 1.0.1"
// 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 | Versions 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. |
-
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.
Exception message refactored to become more visible and readable.