Command line configuration provider implementation for Microsoft.Extensions.Configuration.
Documentation can be found at https://learn.microsoft.com/dotnet/core/extensions/configuration-providers#command-line-configuration-provider
The APIs and functionality are mature, but do get extended occasionally.
Microsoft.Extensions.Configuration.CommandLine is included in the ASP.NET Core shared framework. The package is deployed as out-of-band (OOB) too and can be referenced into projects directly.
The following example shows how to read application configuration from the command line. You can use a command like dotnet run --InputPath "c:\fizz" --OutputPath "c:\buzz"
to run it.
using System;
using Microsoft.Extensions.Configuration;
class Program
{
static void Main(string[] args)
{
// Build a configuration object from command line
IConfiguration config = new ConfigurationBuilder()
.AddCommandLine(args)
.Build();
// Read configuration values
Console.WriteLine($"InputPath: {config["InputPath"]}");
Console.WriteLine($"OutputPath: {config["OutputPath"]}");
}
}