Samhammer.Configuration.Childs 6.0.0

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

// Install Samhammer.Configuration.Childs as a Cake Tool
#tool nuget:?package=Samhammer.Configuration.Childs&version=6.0.0                

Samhammer.Configuration.Childs

Usage

How to add this to your project:

To add it to ASP.NET Core configuration simply place .EnableChildSubstitutions() last. Make sure it is always called after all other configurations are added, else it won't behave properly!

public static IHostBuilder CreateHostBuilder(string[] args) =>
   Host.CreateDefaultBuilder(args)
      .ConfigureAppConfiguration((ctx, builder) =>
      {
          // if you have any additional configuration place it before
          var customer = Environment.GetEnvironmentVariable("CUSTOMER");
          builder.EnableChildSubstitutions(customer);
      });

Set enviroment variable 'Customer' to control which child substitutions are loaded in the configuration. For local development you can do set in launchsettings.json.

"environmentVariables": {
  "ASPNETCORE_ENVIRONMENT": "Development",
  "CUSTOMER": "customer1"
}
When to use it

If you want to deploy multiple production systems (e.g. different customers) and you don´t want to add additional appsettings.json files or additional enviroment variables for all of your settings.

How to use it
Simple Example

Example where the entry ConnectionString in appsettings.json has some default value and some substitutions values for different customers.

{
  "ConnectionString ": "blabla&catalog=myapp",
  "customer1:ConnectionString ": "blabla&catalog=myapp-customer1",
  "customer2:ConnectionString ": "blabla&catalog=myapp-customer2",
}
var value = configuration["ConnectionString"];

This will return 'blabla&catalog=myapp-customer1'.

Additional examples
{
  "DatabaseOptions ": {
    "HostName": "host",
    "CatalogName": "db",
    "UserName": "user"
  },
  "customer1:DatabaseOptions": {
    "CatalogName": "db1",
    "UserName": "user1"  
  }
}
{
  "DatabaseOptions ": {
    "HostName": "host",
    "CatalogName": "db",
    "UserName": "user",
    
    "customer1": {
      "CatalogName": "db1",
      "UserName": "user1"  
    }
  }
}

Contribute

How to publish package
  • Create a tag and let the github action do the publishing for you
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
8.0.0 1,882 3/8/2024
6.0.0 10,827 1/20/2022
3.1.0 6,536 8/21/2020