OpenEnv 26.2.10.5
dotnet add package OpenEnv --version 26.2.10.5
NuGet\Install-Package OpenEnv -Version 26.2.10.5
<PackageReference Include="OpenEnv" Version="26.2.10.5" />
<PackageVersion Include="OpenEnv" Version="26.2.10.5" />
<PackageReference Include="OpenEnv" />
paket add OpenEnv --version 26.2.10.5
#r "nuget: OpenEnv, 26.2.10.5"
#:package OpenEnv@26.2.10.5
#addin nuget:?package=OpenEnv&version=26.2.10.5
#tool nuget:?package=OpenEnv&version=26.2.10.5
OpenEnv
<div align="center"> <img width="512" height="512" alt="OpenEnv Icon" src="https://github.com/user-attachments/assets/b06eeaa8-2916-4af6-8bf0-cd1ca6eb4157" /> </div>
OpenEnv is a lightweight library for managing development, testing, and production environments across .NET applications.
It centralises environment-specific configuration (server IPs, credentials, backups, etc.) and applies them at application startup—removing the need to hard-code or manually swap settings between builds.
Features
- Single configuration file for all environments
- Supports .NET Framework 4.8 and .NET (Core / 8 / 9+)
- Automatically updates connection strings at runtime
- Works with EF / EF Visual Editor
- Keeps sensitive environment data out of source code
Installation
Install via NuGet:
Install-Package OpenEnv
Configuration: Production Server
To properly utilise OpenEnv, you need to add a blank PRODUCTION.ini to the C:\ drive of your production server. This file acts as a marker to identify the production environment.
Configuration: EnvironmentConfig.json
Add an EnvironmentConfig.json file to your project containing the configuration for each environment.
⚠️ Important
This file contains sensitive information.
Do not commit it to public repositories. Add it to .gitignore.
Example
{
"Environments": {
"Development": {
"ServerIP": "",
"SqlCredentials": {
"Username": "",
"Password": ""
},
"NetworkCredentials": {
"Username": "",
"Password": "",
"Domain": ""
},
"BackupLocation": ""
},
"Testing": {
"ServerIP": "",
"SqlCredentials": {
"Username": "",
"Password": ""
},
"NetworkCredentials": {
"Username": "",
"Password": "",
"Domain": ""
},
"BackupLocation": ""
},
"Production": {
"ServerIP": "",
"SqlCredentials": {
"Username": "",
"Password": ""
},
"NetworkCredentials": {
"Username": "",
"Password": "",
"Domain": ""
},
"BackupLocation": ""
}
}
}
Application Startup
OpenEnv must be initialised before your application starts using configuration or database connections.
.NET Framework 4.8
static class Program
{
static void Main()
{
// Initialise using a file path
HostingEnvironment.Initialise("Path/To/Your/EnvironmentConfig.json");
// OR initialise from raw JSON
var json = File.ReadAllText(
Path.Combine(AppContext.BaseDirectory, "EnvironmentConfig.json")
);
HostingEnvironment.InitialiseFromJson(json);
// Continue application startup
}
}
.NET / ASP.NET Core
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Initialise using a file path
HostingEnvironment.Initialise(
"Path/To/Your/EnvironmentConfig.json",
builder
);
// OR initialise from raw JSON
var json = File.ReadAllText(
Path.Combine(AppContext.BaseDirectory, "EnvironmentConfig.json")
);
HostingEnvironment.InitialiseFromJson(json, builder);
// Continue application startup
}
}
Entity Framework (EF) Visual Editor
When using the EF Visual Editor, the connection string name must follow a specific convention.
Step 1: Connection String Name
Set the Connection String Name to:
<MyDatabaseName>Connection
The name must end with Connection.
<img width="415" height="202" alt="EF connection string name example" src="https://github.com/user-attachments/assets/fd7223f6-e72b-4ab4-bb81-30ede24c3093" />
Step 2: Config File Entry
Add the connection string to your app.config or web.config:
<connectionStrings>
<add name="MyDBNameConnection"
connectionString="REPLACEDBYOPENENV"
providerName="System.Data.SqlClient" />
</connectionStrings>
OpenEnv will replace the placeholder value at runtime based on the active environment.
Security Notes
- Treat
EnvironmentConfig.jsonas a secret - Store securely (e.g. local only, secured deployme
| Product | Versions 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Microsoft.Data.SqlClient (>= 6.1.4)
- Microsoft.Extensions.Configuration (>= 10.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.2)
- Newtonsoft.Json (>= 13.0.4)
-
net8.0
- Microsoft.Data.SqlClient (>= 6.1.4)
- Microsoft.Extensions.Configuration (>= 10.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.2)
- Newtonsoft.Json (>= 13.0.4)
-
net9.0
- Microsoft.Data.SqlClient (>= 6.1.4)
- Microsoft.Extensions.Configuration (>= 10.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.2)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OpenEnv:
| Package | Downloads |
|---|---|
|
OpenASU
OpenASU – A lightweight NuGet package providing helper functions to simplify ASP.NET Core Web API setup. |
GitHub repositories
This package is not used by any popular GitHub repositories.
26.2.5 - Initial Publish to NuGet.org.
26.2.6 - Improved Robustness, Included Dynamic Logger on Initialise and Removed DB Operations from Library.
26.2.10 - Expose Environment Keys for GetEnvironmentConfig.
26.2.10.1 - Use GetEnvironmentKey instead of exposing public keys.
26.2.10.2 - Expose BuildConnectionString.
26.2.10.3 - Add GetDbCatalogFromMode.
26.2.10.4 - Include Missing BackupLocation in GetEnvironmentConfig.
26.2.10.5 - Fixing Deserialisation of Password with intermediate DTO.