Curiosus.Configuration.YML
2.1.0
dotnet add package Curiosus.Configuration.YML --version 2.1.0
NuGet\Install-Package Curiosus.Configuration.YML -Version 2.1.0
<PackageReference Include="Curiosus.Configuration.YML" Version="2.1.0" />
<PackageVersion Include="Curiosus.Configuration.YML" Version="2.1.0" />
<PackageReference Include="Curiosus.Configuration.YML" />
paket add Curiosus.Configuration.YML --version 2.1.0
#r "nuget: Curiosus.Configuration.YML, 2.1.0"
#:package Curiosus.Configuration.YML@2.1.0
#addin nuget:?package=Curiosus.Configuration.YML&version=2.1.0
#tool nuget:?package=Curiosus.Configuration.YML&version=2.1.0
Curiosus.Configuration.YML
YAML configuration provider: YamlConfigurationProvider<T> reads layered config*.yml files, environment
variables and command line arguments and binds them to a POCO. Use it when the application is configured
with YAML files instead of appsettings.json.
Installation
dotnet add package Curiosus.Configuration.YML
Usage
Files are looked up in the given directory (the current directory if null), in this order:
| File | Required | Loaded when |
|---|---|---|
config.yml |
yes (unless isConfigOptional: true) |
always |
config.secret.yml |
no | always |
config.{env}.yml, config.{env}.secret.yml |
no | ASPNETCORE_ENVIRONMENT is set and is not Production |
config.{env}.{USER}.yml, config.{env}.{USER}.secret.yml |
no | as above and USER is set |
Environment variables and command line arguments are applied on top. Keep *.secret.yml out of source control.
# config.yml
ServiceUrl: https://example.com
Smtp:
Host: smtp.example.com
Port: 587
using Curiosus.Configuration;
var provider = new YamlConfigurationProvider<AppConfiguration>(configurationBasePath: null, cliArgs: args);
var configuration = provider.GetConfiguration(); // strongly typed, cached
var raw = provider.GetRawConfiguration(); // IConfiguration
// or plug the same sources into a host
var builder = WebApplication.CreateBuilder(args);
provider.ConfigureAppConfiguration(builder.Configuration);
public class AppConfiguration
{
public string ServiceUrl { get; set; } = null!;
public SmtpSection Smtp { get; set; } = new();
}
public class SmtpSection
{
public string Host { get; set; } = null!;
public int Port { get; set; }
}
Note: the provider lives in the Curiosus.Configuration namespace.
See also
- Curiosus.Configuration — options validation, logging and the base provider
- Curiosus.Utils — all packages
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 is compatible. 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. |
-
net10.0
- Curiosus.Configuration (>= 2.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.3)
- NetEscapades.Configuration.Yaml (>= 3.0.0)
-
net9.0
- Curiosus.Configuration (>= 2.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.13)
- NetEscapades.Configuration.Yaml (>= 3.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Curiosus.Configuration.YML:
| Package | Downloads |
|---|---|
|
Curiosus.Hosting
Hosting tools |
GitHub repositories
This package is not used by any popular GitHub repositories.