Workleap.Extensions.Configuration.Substitution
1.1.16
Prefix Reserved
See the version list below for details.
dotnet add package Workleap.Extensions.Configuration.Substitution --version 1.1.16
NuGet\Install-Package Workleap.Extensions.Configuration.Substitution -Version 1.1.16
<PackageReference Include="Workleap.Extensions.Configuration.Substitution" Version="1.1.16" />
<PackageVersion Include="Workleap.Extensions.Configuration.Substitution" Version="1.1.16" />
<PackageReference Include="Workleap.Extensions.Configuration.Substitution" />
paket add Workleap.Extensions.Configuration.Substitution --version 1.1.16
#r "nuget: Workleap.Extensions.Configuration.Substitution, 1.1.16"
#addin nuget:?package=Workleap.Extensions.Configuration.Substitution&version=1.1.16
#tool nuget:?package=Workleap.Extensions.Configuration.Substitution&version=1.1.16
Workleap.Extensions.Configuration.Substitution
This package adds variable substitution configuration provider implementation for Microsoft.Extensions.Configuration.
Getting started
dotnet add package Workleap.Extensions.Configuration.Substitution
// Example for an ASP.NET Core web application
var builder = WebApplication.CreateBuilder(args);
// Setup your configuration
builder.Configuration.AddJsonFile("appsettings.json");
builder.Configuration.AddEnvironmentVariables();
builder.Configuration.AddSubstitution(); // <-- Add this after other configuration providers
How it works
You can reference configuration values inside other configuration values by enclosing the referenced configuration key like this: ${ReferencedConfigurationKey}
.
Examples
Consider this appsettings.json
:
{
"Credentials": {
"Username": "alice1",
"Password": "P@ssw0rd"
},
"ConnectionString": "usr=${Credentials:Username};pwd=${Credentials:Password}"
}
Evaluating the configuration value ConnectionString
would return usr=alice1;pwd=P@ssw0rd
.
This also works if you're using multiple configuration providers. For instance, one could have the Credentials:Password
configuration value provided by a secret from Azure Key Vault and this value would have been injected into the ConnectionString
value too.
It also works with arrays:
{
"Credentials": [ "alice1", "P@ssw0rd" ],
"ConnectionString": "usr=${Credentials:0};pwd=${Credentials:1}"
}
Again, you're not limited to JSON file providers, you could use substitution with any configuration providers. It was easier to use JSON files in these examples.
Escaping values
You might not want a specific value to be substituted. In that case, escape it using double curly braces:
{
"Foo": "foo",
"Bar": "${{Foo}}"
}
Evaluating the configuration value Bar
would return ${Foo}
.
Exceptions
You can encounter two kinds of exceptions if your configuration is incorrect:
UnresolvedConfigurationKeyException
, if you're trying to substitute a configuration value that is undefined (i.e. the key does not exist).RecursiveConfigurationKeyException
, if you have many configuration values that reference each other in a recursive manner, no matter how deep the recursion is. The exception will give you details about the recursive path.
UnresolvedConfigurationKeyException
can also be triggered sooner than later by using AddSubstitution(eagerValidation: true)
. Using eagerValidation
with value true
(default is false
) instructs the library to check for undefined values in all the existing configuration values once, instead of checking for a particular value. This happens as soon as any configuration value is loaded.
Configuration providers order
When using .NET's IConfigurationBuilder, the order of configuration providers matters . Any configuration provider added after AddSubstitution()
would not benefit from the substitution process.
License
Copyright © 2022, Workleap. This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license at https://github.com/workleap/gsoft-license/blob/master/LICENSE.
Product | Versions 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 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. 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 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. |
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration (>= 6.0.0)
-
net8.0
- Microsoft.Extensions.Configuration (>= 6.0.0)
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 |
---|---|---|
1.1.17-preview.2 | 104 | 6/18/2025 |
1.1.16 | 332 | 6/15/2025 |
1.1.16-preview.2 | 105 | 6/14/2025 |
1.1.16-preview.1 | 278 | 6/10/2025 |
1.1.15 | 1,009 | 6/8/2025 |
1.1.15-preview.2 | 83 | 6/8/2025 |
1.1.15-preview.1 | 109 | 6/3/2025 |
1.1.14 | 788 | 6/1/2025 |
1.1.14-preview.1 | 113 | 5/26/2025 |
1.1.13 | 458 | 5/25/2025 |
1.1.13-preview.3 | 68 | 5/25/2025 |
1.1.13-preview.2 | 68 | 5/23/2025 |
1.1.13-preview.1 | 111 | 5/20/2025 |
1.1.12 | 334 | 5/18/2025 |
1.1.12-preview.2 | 104 | 5/17/2025 |
1.1.12-preview.1 | 204 | 5/13/2025 |
1.1.11 | 1,367 | 5/11/2025 |
1.1.11-preview.1 | 112 | 5/6/2025 |
1.1.10 | 699 | 5/4/2025 |
1.1.10-preview.1 | 125 | 4/29/2025 |
1.1.9 | 297 | 4/27/2025 |
1.1.9-preview.2 | 86 | 4/25/2025 |
1.1.9-preview.1 | 115 | 4/22/2025 |
1.1.8-preview.1 | 626 | 4/14/2025 |
1.1.7-preview.1 | 83 | 4/11/2025 |
1.1.6-preview.3 | 126 | 4/7/2025 |
1.1.6-preview.2 | 126 | 4/1/2025 |
1.1.6-preview.1 | 125 | 4/1/2025 |
1.1.5 | 8,626 | 3/20/2025 |
1.1.5-preview.13 | 121 | 3/20/2025 |
1.1.5-preview.12 | 120 | 3/20/2025 |
1.1.5-preview.11 | 121 | 3/20/2025 |
1.1.5-preview.10 | 122 | 3/20/2025 |
1.1.5-preview.9 | 46 | 3/15/2025 |
1.1.5-preview.8 | 133 | 3/11/2025 |
1.1.5-preview.7 | 81 | 2/18/2025 |
1.1.5-preview.6 | 76 | 2/17/2025 |
1.1.5-preview.5 | 69 | 2/16/2025 |
1.1.5-preview.4 | 75 | 2/15/2025 |
1.1.5-preview.3 | 73 | 2/12/2025 |
1.1.5-preview.2 | 72 | 1/30/2025 |
1.1.5-preview.1 | 72 | 1/24/2025 |
1.1.4 | 29,150 | 1/21/2025 |
1.1.4-preview.16 | 68 | 1/17/2025 |
1.1.4-preview.15 | 61 | 1/13/2025 |
1.1.4-preview.13 | 76 | 12/18/2024 |
1.1.4-preview.12 | 475 | 11/29/2024 |
1.1.4-preview.11 | 71 | 11/24/2024 |
1.1.4-preview.10 | 64 | 11/16/2024 |
1.1.4-preview.9 | 65 | 10/31/2024 |
1.1.4-preview.8 | 68 | 10/30/2024 |
1.1.4-preview.7 | 70 | 10/28/2024 |
1.1.4-preview.6 | 69 | 10/28/2024 |
1.1.4-preview.5 | 69 | 10/28/2024 |
1.1.4-preview.4 | 64 | 10/7/2024 |
1.1.4-preview.3 | 70 | 10/1/2024 |
1.1.4-preview.2 | 70 | 9/30/2024 |
1.1.4-preview.1 | 77 | 9/27/2024 |
1.1.3 | 41,777 | 9/23/2024 |
1.1.3-preview.48 | 74 | 9/20/2024 |
1.1.3-preview.47 | 74 | 9/13/2024 |
1.1.3-preview.46 | 72 | 8/27/2024 |
1.1.3-preview.45 | 71 | 8/27/2024 |
1.1.3-preview.44 | 72 | 8/27/2024 |
1.1.3-preview.43 | 69 | 8/27/2024 |
1.1.3-preview.42 | 85 | 8/16/2024 |
1.1.3-preview.41 | 71 | 7/30/2024 |
1.1.3-preview.40 | 95 | 7/18/2024 |
1.1.3-preview.39 | 72 | 7/18/2024 |
1.1.3-preview.38 | 68 | 7/5/2024 |
1.1.3-preview.37 | 76 | 5/31/2024 |
1.1.3-preview.36 | 72 | 5/31/2024 |
1.1.3-preview.35 | 74 | 5/21/2024 |
1.1.3-preview.34 | 84 | 5/10/2024 |
1.1.3-preview.33 | 72 | 5/3/2024 |
1.1.3-preview.32 | 139 | 4/15/2024 |
1.1.3-preview.31 | 91 | 4/12/2024 |
1.1.3-preview.30 | 89 | 4/3/2024 |
1.1.3-preview.29 | 86 | 4/3/2024 |
1.1.3-preview.28 | 88 | 3/8/2024 |
1.1.3-preview.27 | 81 | 3/7/2024 |
1.1.3-preview.26 | 83 | 3/4/2024 |
1.1.3-preview.25 | 88 | 3/1/2024 |
1.1.3-preview.24 | 88 | 2/16/2024 |
1.1.3-preview.23 | 84 | 2/12/2024 |
1.1.3-preview.22 | 95 | 2/6/2024 |
1.1.3-preview.21 | 82 | 2/6/2024 |
1.1.3-preview.20 | 86 | 1/22/2024 |
1.1.3-preview.19 | 83 | 1/12/2024 |
1.1.3-preview.18 | 79 | 1/12/2024 |
1.1.3-preview.17 | 78 | 1/12/2024 |
1.1.3-preview.16 | 98 | 12/18/2023 |
1.1.3-preview.15 | 115 | 11/26/2023 |
1.1.3-preview.14 | 101 | 11/17/2023 |
1.1.3-preview.13 | 83 | 11/13/2023 |
1.1.3-preview.12 | 167 | 11/6/2023 |
1.1.3-preview.11 | 102 | 10/30/2023 |
1.1.3-preview.10 | 99 | 10/20/2023 |
1.1.3-preview.9 | 102 | 10/17/2023 |
1.1.3-preview.8 | 103 | 10/13/2023 |
1.1.3-preview.7 | 99 | 9/26/2023 |
1.1.3-preview.6 | 93 | 9/25/2023 |
1.1.3-preview.5 | 87 | 9/21/2023 |
1.1.3-preview.4 | 89 | 9/20/2023 |
1.1.3-preview.3 | 95 | 9/20/2023 |
1.1.3-preview.2 | 94 | 9/20/2023 |
1.1.3-preview.1 | 111 | 8/9/2023 |
1.1.2 | 117,308 | 7/20/2023 |
1.1.2-preview.20 | 115 | 7/20/2023 |