ToolBox.ConfigGeneration 1.0.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package ToolBox.ConfigGeneration --version 1.0.8                
NuGet\Install-Package ToolBox.ConfigGeneration -Version 1.0.8                
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="ToolBox.ConfigGeneration" Version="1.0.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ToolBox.ConfigGeneration --version 1.0.8                
#r "nuget: ToolBox.ConfigGeneration, 1.0.8"                
#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 ToolBox.ConfigGeneration as a Cake Addin
#addin nuget:?package=ToolBox.ConfigGeneration&version=1.0.8

// Install ToolBox.ConfigGeneration as a Cake Tool
#tool nuget:?package=ToolBox.ConfigGeneration&version=1.0.8                

ToolBox.ConfigGeneration

ConfigGeneration is a library which helps to streamline the interaction with runtime configurations.

Instead of maintaining an enormous appsettings.json file or registering your IOptions<T> to your service collection again and again, this library takes care of automating this for you.

Introduction

When using ToolBox.ConfigGeneration, you declare your configuration in a Domain Driven Design manner.
Practically, this means that instead of maintaining a single appsettings file for all configurations - you manage each configuration.

For example, say you have a redis configuration:

public class RedisConfiguration {
    public string RedisUri { get; set; }
}

and a postgres db configuration:

public class PostgresConfiguration {
    public string DbUri { get; set; }
}

For each of those you will define a json file with an equivalent name.
Below is the example for the RedisConfiguration.json:

RedisConfiguration

{
    "RedisUri": {
        "development": {
            "eastus": "https://...",
            "westeurope": "https://..."
        },
        "production": {
            "eastus": "https://...",
            "westeurope": "https://..."
        }
    }
}

Note the inner hierarchy defined under the RedisUri property.

You have full control over the hierarchy of your configurations.

See below section for more info.

Hierarchy file

In your executable project, you define a single hierarchy file.

Your hierarchy will be defined by the various deployment environments, regions / locations or any other granularity you might need.

The hierarchy file is a .json file and must have two key-value pairs:

  1. hierarchy (array) - a list of nested hierarchies, by order.
  2. combinations (array) - a list of all combinations that must have their own dedicated settings.

For example, the hierarchy file suitable to fit the above RedisConfiguration.json is:

hierarchy.json

{
    "hierarchy": ["environment", "region"],
    "combinations": [
        {
            "environment": "development",
            "region": "eastus"
        },
        {
            "environment": "development",
            "region": "westeurope"
        },
        {
            "environment": "production",
            "region": "eastus"
        },
        {
            "environment": "production",
            "region": "westeurope"
        },
    ]
}

As you can see, there are 4 combinations defined in the above file.
This means there is a total of 4 distinct environments - each deserving of its own set of configuration values.

Read below section to learn how to generate the configurations

Configuration generation

<Target Name="RunConfigTool" BeforeTargets="BeforeBuild">
    
    <Message Importance="High" Text="Checking if tool manifest exists..." />

    
    <Exec Command="dotnet new tool-manifest" ContinueOnError="true" />

    
    <Message Importance="High" Text="Ensuring toolbox-config-gen is installed..." />

    
    <Exec Command="dotnet tool install toolbox-config-gen --local" ContinueOnError="true" />

    
    <Message Importance="High" Text="Running toolbox-config-gen to generate configuration..." />

    
    <Exec Command="dotnet tool run toolbox-config-gen --inputDirectoryPath $(ProjectDir)src/configuration --outputDirectoryPath $(ProjectDir)src/configuration/generated --hierarchyFilePath $(ProjectDir)src/configuration/hierarchy.json" />
  </Target>
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 was computed.  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. 
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 ToolBox.ConfigGeneration:

Package Downloads
ConfigGenerationSample

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.5.0 100 1/1/2025
1.4.0 84 12/24/2024
1.3.0 87 12/23/2024
1.2.1 74 12/23/2024
1.2.0 82 12/23/2024
1.1.1 85 12/22/2024
1.1.0 90 12/22/2024
1.0.9 89 12/19/2024
1.0.8 80 12/19/2024
1.0.7 85 12/19/2024
1.0.6 82 12/19/2024
1.0.5 81 12/19/2024
1.0.3 82 12/18/2024
1.0.0 87 12/18/2024