Corner49.Infra.CLI
10.0.169
dotnet add package Corner49.Infra.CLI --version 10.0.169
NuGet\Install-Package Corner49.Infra.CLI -Version 10.0.169
<PackageReference Include="Corner49.Infra.CLI" Version="10.0.169" />
<PackageVersion Include="Corner49.Infra.CLI" Version="10.0.169" />
<PackageReference Include="Corner49.Infra.CLI" />
paket add Corner49.Infra.CLI --version 10.0.169
#r "nuget: Corner49.Infra.CLI, 10.0.169"
#:package Corner49.Infra.CLI@10.0.169
#addin nuget:?package=Corner49.Infra.CLI&version=10.0.169
#tool nuget:?package=Corner49.Infra.CLI&version=10.0.169
Corner49.Infra.CLI
Opinionated bootstrap for .NET console apps, workers and containerised jobs. Part of Corner49.Infra – a set of packages that provide opinionated tooling for infrastructure in .NET applications.
It gives a generic host the same configuration, logging and extension model that Corner49.Infra gives a web app, and adds two ways to decide what the process does: named jobs or System.CommandLine.
dotnet add package Corner49.Infra.CLI
Do not reference this package together with Corner49.Infra in the same project; both define Corner49.Infra.InfraBuilder.
Getting started
using Corner49.Infra;
var infra = InfraBuilder.Create("MyTool", args)
.WithLogging(opt => opt.WriteToConsoleAsJson = false);
infra.AddJob<HelloWorldJob>("Hello", "Print hello world in the console");
infra.AddJob<ImportJob>("Import", "Import the nightly product feed");
await infra.BuildAndRun(args);
using Corner49.Infra.Jobs;
public class ImportJob : IJob {
private readonly IProductRepo _repo;
public ImportJob(IProductRepo repo) {
_repo = repo;
}
public async Task Execute(string[]? args = null, CancellationToken cancellationToken = default) {
// args[0] is the job name, the rest are your own arguments
}
}
Run a job by passing its name as the first argument (not case sensitive):
MyTool import 2026-10-07
Running without arguments prints the registered jobs and their descriptions.
What BuildAndRun(args) does
After building the host and starting the registered extensions, it picks one of three modes:
| Registered | Behaviour |
|---|---|
WithCommandLine(...) |
Parses args with your System.CommandLine root command and invokes it. Takes precedence over jobs. |
One or more AddJob<T>(...) |
Runs the job named by args[0], then exits. |
| Neither | Runs the host until shutdown (RunAsync), for hosted services and workers. |
Builder API
| Method | Purpose |
|---|---|
InfraBuilder.Create(name, args) |
Creates a HostApplicationBuilder and calls UseInfra on it. |
builder.UseInfra(name, environment?) |
Same, for an existing IHostApplicationBuilder. |
WithOptions<T>(section?) |
Binds a configuration section to T. The section name defaults to the type name without its Options or Configuration suffix. |
WithLogging(options?) |
Activity tracking, optional JSON console output and category-prefix filtering (errors always pass the filter). A plain console logger is added when a debugger is attached or ConsoleLog=true is set. |
AddJob<T>(name, description?) |
Registers an IJob as a keyed singleton under name. |
WithCommandLine(cmd => ..., description) |
Configures a System.CommandLine RootCommand. |
AddExtension(extension) |
Adds an InfraExtension; this is what AddDocumentDB, AddServiceBus and friends use. |
Services, Configuration |
The underlying IServiceCollection and IConfigurationManager for your own registrations. |
After the host is built, InfraBuilder.Instance.Services exposes the service provider for code that cannot use constructor injection.
Configuration
UseInfra loads, in this order:
appsettings.jsonappsettings.{Environment}.jsonappsettings.{MachineName}.json- Environment variables
All files are optional. If that configuration contains an AppConfig connection string, Azure App Configuration is added underneath it (unlabelled keys, then keys labelled with the environment name, then keys labelled with the machine name). Local settings always override App Configuration.
Using the Azure packages
infra.AddDocumentDB(db => db.AddRepo<IProductRepo, ProductRepo>()); // Corner49.Infra.AzureCosmosDB
infra.AddServiceBus(cfg => { }); // Corner49.Infra.AzureServiceBus
infra.AddBlobService("Documents"); // Corner49.Infra.AzureStorage
Repositories registered this way can be injected straight into your jobs.
Related packages
- Corner49.Infra.Core – abstractions and utilities
- Corner49.Infra.AzureCosmosDB
- Corner49.Infra.AzureServiceBus
- Corner49.Infra.AzureStorage
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Corner49.Infra.Core (>= 10.0.169)
- Microsoft.Extensions.Configuration.AzureAppConfiguration (>= 8.6.0)
- Microsoft.Extensions.Hosting (>= 10.0.12)
- Microsoft.Extensions.Logging (>= 10.0.12)
- System.CommandLine (>= 2.0.12)
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 |
|---|---|---|
| 10.0.169 | 43 | 10/21/2026 |
| 10.0.168 | 47 | 10/21/2026 |
| 10.0.167 | 48 | 10/21/2026 |
| 10.0.166 | 59 | 10/20/2026 |
| 10.0.165 | 59 | 10/20/2026 |
| 10.0.164 | 55 | 10/20/2026 |
| 10.0.163 | 51 | 10/20/2026 |
| 10.0.162 | 51 | 10/20/2026 |
| 10.0.161 | 51 | 10/20/2026 |
| 10.0.159 | 55 | 10/20/2026 |
| 10.0.158 | 70 | 10/19/2026 |
| 10.0.157 | 59 | 10/19/2026 |
| 10.0.156 | 64 | 10/16/2026 |
| 10.0.154 | 84 | 10/14/2026 |
| 10.0.153 | 87 | 10/14/2026 |
| 10.0.151 | 106 | 10/8/2026 |
| 10.0.150 | 88 | 10/8/2026 |
| 10.0.149 | 83 | 10/8/2026 |
| 10.0.148 | 90 | 10/8/2026 |
| 10.0.147 | 91 | 10/8/2026 |