Back to results for “Set”
.NET › Configuration & Options

How does the command-line configuration provider let you override settings via arguments when running an application?

Intermediate

Answer

The command-line provider (added by default in the host builder) parses arguments in --Key=Value or --Key Value format (and supports colon-delimited nested keys) as the highest-precedence configuration source by default, letting you override any setting for a single run without modifying files or environment variables -- useful for quick local testing or scripted one-off overrides.
dotnet run --ConnectionStrings:DefaultConnection="Server=test;" --Logging:LogLevel:Default=Debug

// Equivalent to setting these keys via any other provider, but only for this single run
Real-world example A developer debugging a production-like issue locally runs `dotnet run --Logging:LogLevel:Default=Trace` for one session to get maximally verbose logging without permanently changing any configuration file.

Common follow-ups: Does the command-line provider support short-form argument aliases?;How does this interact with environment-variable overrides in terms of precedence?