Microsoft.Extensions.Configuration
10.0.12
Prefix Reserved
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.2
This package targets .NET Framework 4.6.2. The package is compatible with this framework or higher.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Microsoft.Extensions.Configuration --version 10.0.12
NuGet\Install-Package Microsoft.Extensions.Configuration -Version 10.0.12
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="Microsoft.Extensions.Configuration" Version="10.0.12" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.12" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
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 Microsoft.Extensions.Configuration --version 10.0.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Microsoft.Extensions.Configuration, 10.0.12"
#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 Microsoft.Extensions.Configuration@10.0.12
#: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=Microsoft.Extensions.Configuration&version=10.0.12
#tool nuget:?package=Microsoft.Extensions.Configuration&version=10.0.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
About
Microsoft.Extensions.Configuration is combined with a core configuration abstraction under Microsoft.Extensions.Configuration.Abstractions that allows for building different kinds of configuration providers to retrieve key/value pair configuration values from in the form of IConfiguration. There are a number of built-in configuration provider implementations to read from environment variables, in-memory collections, JSON, INI or XML files. Aside from the built-in variations, there are more shipped libraries shipped by community for integration with various configuration service and other data sources.
Key Features
- In-memory configuration provider
- Chained configuration provider for chaining multiple confiugration providers together.
- Base types that implement configuration abstraction interfaces that can be used when implementing other configuration providers.
How to Use
using Microsoft.Extensions.Configuration;
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddInMemoryCollection(
new Dictionary<string, string?>
{
["Setting1"] = "value",
["MyOptions:Enabled"] = bool.TrueString,
});
configurationBuilder.AddInMemoryCollection(
new Dictionary<string, string?>
{
["Setting2"] = "value2",
["MyOptions:Enabled"] = bool.FalseString,
});
var config = configurationBuilder.Build();
// note case-insensitive
Console.WriteLine(config["setting1"]);
Console.WriteLine(config["setting2"]);
// note last in wins
Console.WriteLine(config["MyOptions:Enabled"]);
Main Types
The main types provided by this library are:
Microsoft.Extensions.Configuration.ConfigurationBuilderMicrosoft.Extensions.Configuration.ConfigurationManagerMicrosoft.Extensions.Configuration.ConfigurationRootMicrosoft.Extensions.Configuration.ConfigurationSection