OpenEnv 26.2.10.5

dotnet add package OpenEnv --version 26.2.10.5
                    
NuGet\Install-Package OpenEnv -Version 26.2.10.5
                    
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="OpenEnv" Version="26.2.10.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenEnv" Version="26.2.10.5" />
                    
Directory.Packages.props
<PackageReference Include="OpenEnv" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenEnv --version 26.2.10.5
                    
#r "nuget: OpenEnv, 26.2.10.5"
                    
#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.
#:package OpenEnv@26.2.10.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenEnv&version=26.2.10.5
                    
Install as a Cake Addin
#tool nuget:?package=OpenEnv&version=26.2.10.5
                    
Install as a Cake Tool

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.json as a secret
  • Store securely (e.g. local only, secured deployme
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.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
26.2.10.5 173 2/10/2026
26.2.10.4 110 2/10/2026
26.2.10.3 107 2/10/2026
26.2.10.2 108 2/10/2026
26.2.10.1 104 2/9/2026
26.2.10 106 2/9/2026
26.2.6 105 2/6/2026
26.2.5 112 2/5/2026

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.