ApplicationBuilderHelpers 4.1.142

This package has a SemVer 2.0.0 package version: 4.1.142+build.20260923094141.73156fb.
There is a newer version of this package available.
See the version list below for details.
dotnet add package ApplicationBuilderHelpers --version 4.1.142
                    
NuGet\Install-Package ApplicationBuilderHelpers -Version 4.1.142
                    
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="ApplicationBuilderHelpers" Version="4.1.142" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ApplicationBuilderHelpers" Version="4.1.142" />
                    
Directory.Packages.props
<PackageReference Include="ApplicationBuilderHelpers" />
                    
Project file
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 ApplicationBuilderHelpers --version 4.1.142
                    
#r "nuget: ApplicationBuilderHelpers, 4.1.142"
                    
#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 ApplicationBuilderHelpers@4.1.142
                    
#: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=ApplicationBuilderHelpers&version=4.1.142
                    
Install as a Cake Addin
#tool nuget:?package=ApplicationBuilderHelpers&version=4.1.142
                    
Install as a Cake Tool

ApplicationBuilderHelpers

A .NET library for building command-line applications with a fluent API, dependency injection, and modular architecture.

  • Targets: net6.0โ€“net10.0 ยท AOT-compatible ยท Trimmable
  • Dependencies: Microsoft.Extensions.Hosting, Microsoft.Extensions.DependencyInjection.Abstractions, AbsolutePathHelpers

Features

  • ๐ŸŽฏ Command-based Architecture โ€” Command patterns with automatic argument parsing
  • ๐Ÿ”ง Fluent Builder API โ€” Intuitive setup via method chaining
  • ๐Ÿ’‰ Dependency Injection โ€” Full Microsoft.Extensions.DependencyInjection support
  • ๐Ÿ—๏ธ Modular Application Structure โ€” Reusable ApplicationDependency modules with lifecycle hooks
  • โš™๏ธ Configuration โ€” .NET configuration integration with @ref: reference values
  • ๐ŸŽจ Attributes โ€” [Command], [CommandOption], [CommandArgument] for declarative CLI definitions
  • ๐ŸŽฏ Sub-Commands โ€” Hierarchical commands via space-separated names
  • ๐Ÿ–Œ๏ธ Themable Help โ€” 5 built-in console color themes, configurable help width
  • ๐Ÿงฉ Multiple Host Types โ€” HostApplicationBuilder, WebApplicationBuilder, custom builders

Installation

dotnet add package ApplicationBuilderHelpers

Quick Start

// Program.cs
using ApplicationBuilderHelpers;

return await ApplicationBuilder.Create()
    .AddApplication<CoreApplication>()
    .AddCommand<GreetCommand>()
    .RunAsync(args);
[Command(description: "Greet someone")]
public class GreetCommand : Command
{
    [CommandArgument(Name = "name", Position = 0, Description = "Who to greet")]
    public string Name { get; set; } = "World";

    protected override ValueTask Run(ApplicationHost<HostApplicationBuilder> applicationHost, CancellationToken cancellationToken)
    {
        Console.WriteLine($"Hello, {Name}!");
        return ValueTask.CompletedTask;
    }
}
$ myapp Alice
Hello, Alice!

Core Concepts

Commands

Extend Command and override Run. Define options with [CommandOption] and positional arguments with [CommandArgument]. Commands can register their own services, middleware, and configuration โ€” they inherit the full ApplicationDependency lifecycle.

[Command("build", description: "Build the project")]
public class BuildCommand : Command
{
    [CommandOption('v', "verbose", Description = "Enable verbose output")]
    public bool Verbose { get; set; }

    protected override async ValueTask Run(ApplicationHost<HostApplicationBuilder> applicationHost, CancellationToken cancellationToken)
    {
        // ...build logic...
    }
}

ApplicationDependency

Group shared services and configuration into reusable modules:

public class CoreApplication : ApplicationDependency
{
    public override void AddServices(ApplicationHostBuilder appBuilder, IServiceCollection services)
    {
        services.AddSingleton<IMyService, MyService>();
    }
}

See Application Dependencies for the full lifecycle reference.

Sub-Commands

Use space-separated names for hierarchical commands. Try myapp deploy prod or myapp deploy prod rollback:

[Command("deploy prod", description: "Deploy to production")]
public class DeployProductionCommand : Command { /* ... */ }

Exit Codes

RunAsync returns an exit code:

Outcome Exit code
Run returns normally (also --help / --version) 0 (conversion failure beats help-with-values; invalid+version still 0 via the pre-validation version guard at CommandLineParser.cs:83-87)
Usage / validation error (UnknownOption, MissingRequired, RequiresSubcommand, InvalidValue, UnknownCommand; DuplicateOption is reserved and never thrown โ€” valued repeats resolve last-wins) 2
Unexpected fault (Fault, NoImplementation, or Run throwing CommandException with a custom code) 1 or ex.ExitCode (custom host-code passthrough preserved)
Cancellation (CancellationToken / Ctrl+C) 130 (128 + SIGINT)

Bare root (no root implementation, only leaf subcommands): myapp with zero args exits 2 with '<root>' requires a subcommand. Available subcommands: ... plus the two-sentence global usage footer (SubCommandInfo.cs:32; ArgumentParser.cs:71-83; CommandErrorFooter.cs:20-23). Help-first (myapp --help greet) renders global help, exit 0 (ArgumentParser.cs:64-70; HelpFormatter.cs:42-44) โ€” see Advanced Topics.

Return normally on success. Throw CommandException for errors to return a non-zero exit code from RunAsync:

throw new CommandException("Operation failed", exitCode: 1);

Shell completion (complete / completions ...) resolves through the CompletionGateway pre-parse stage first โ€” see Commands for the consolidated 0/1/2 exit matrix.

See Advanced Topics for more on sub-commands, custom host types, error handling, and error footers. Every help screen (global and per-command) lists -V, --version under GLOBAL OPTIONS:; usage-error footers hint at both --help and --version, while Fault/NoImplementation keep the single-sentence --help-only footer.

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ApplicationBuilder โ”‚ โ† Entry Point (fluent API)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚  Commands   โ”‚ โ† Command Registration (+ own lifecycle hooks)
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚  Applications   โ”‚ โ† Application Modules (lifecycle hooks)
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚  Host Builder    โ”‚ โ† Host Configuration
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚  Services   โ”‚ โ† Dependency Injection
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚  Middleware     โ”‚ โ† Request Pipeline
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚  Execution  โ”‚ โ† Command Execution
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

RunAsync pipeline stages: hierarchy build โ†’ CompletionGateway (completion > help > parse > version) โ†’ help โ†’ parse โ†’ version check โ†’ execute.

Documentation

Guide
Getting Started Installation, first app, services
Commands Attributes, options, arguments, lifecycle
Application Dependencies Full lifecycle reference
Configuration & Themes Fluent config, themes, @ref: system, help formatting
Custom Type Parsers ICommandTypeParser / CommandTypeParser<T>
Advanced Topics Sub-commands, host types, exit codes, error handling
API Reference Complete public API surface

Contributing

Contributions are welcome! Please submit a Pull Request.

License

MIT โ€” see the LICENSE file.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
4.1.143 24 9/27/2026
4.1.142 37 9/23/2026
4.1.141 42 9/17/2026
4.1.140 40 9/16/2026
4.1.139 40 9/16/2026
4.1.138 39 9/15/2026
4.1.137 37 9/15/2026
4.1.136 42 9/14/2026
4.1.135 48 9/10/2026
4.1.134 347 9/9/2026
4.1.133 41 9/9/2026
4.1.132 46 9/9/2026
4.1.131 94 9/7/2026
4.1.130 59 9/4/2026
4.1.129 86 8/17/2026
4.1.128 45 8/17/2026
4.1.127 78 8/14/2026
4.1.126 49 8/13/2026
4.1.125 49 8/13/2026
4.1.124 67 8/12/2026
Loading failed

## New Version
* Bump `application_builder_helpers` from `4.1.141` to `4.1.142`. See [changelog](https://github.com/Kiryuumaru/ApplicationBuilderHelpers/compare/application_builder_helpers/4.1.141...application_builder_helpers/4.1.142)

## What's Changed
* fix(cli): invariant-culture scalar parsing (Fixes #451, root cause: ambient-culture TryParse/ChangeType) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/472
* fix(cli): harden SetHelpWidth boundary + floor help layout at 60 (Fixes #450) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/471
* fix(cli): reject flag-looking valued-option neighbors (Fixes #469) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/475
* fix(cli): friendly help placeholders (Fixes #454) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/473
* refactor(cli): split HelpFormatter into content/layout/model (Fixes #456) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/476
* refactor(cli): extract CommandExecutor lifecycle collaborators (Fixes #455) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/479
* fix(cli): shared global-option identity (Fixes #453) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/477
* refactor(cli): unify option/argument construction path (Fixes #452) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/474
* fix(cli): unknown-shell completion script exits 2 via shared canonicalizer by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/494
* feat(cli): share enum auto-population with positional arguments (Fixes #478) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/495
* fix: fail satisfied-required bare repeat as missing (Fixes #470) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/500
* fix(cli): route CancelKeyPress fallback notes to stdout by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/506
* chore(skills): normalize two frontmatter names to lowercase-hyphen by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/514
* fix(cli): fail trailing-bare valued option with flag neighbor as missing (Fixes #503) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/515
* fix(cli): substitute command path in per-command error footers (Fixes #504) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/516
* cli: remove obsolete GetTypeDisplayName leaf, point ADR to HelpTypeDisplay (Fixes #492) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/517
* fix(cli): report registration-time default in help for instance commands (Fixes #481) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/518
* cli: route help categorization via IsGlobal and command lineage (Fixes #491) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/521
* fix(cli): normalize mixed-type FromAmong candidates before Equals (Fixes #486) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/519
* refactor(cli): dedup help colon-split branches via shared wrap routine (Fixes #490) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/522
* fix(cli): aggregate missing-required and invalid-value errors (Fixes #496) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/520
* fix(cli): unify CLI-bound identity and share cache core (Fixes #488) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/523
* refactor(cli): delegate help option signature to single builder (Fixes #489) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/525
* fix(cli): bare numeric token wins over digit short by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/524
* cli: probe conversions before help-with-values so InvalidValue beats help (Fixes #483) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/526
* fix(cli): append did-you-mean on RequiresSubcommand near-miss (Fixes #498) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/527
* docs: align DuplicateOption docs to last-wins per #497 by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/528
* fix(cli): harden merged-copy bind preference (Fixes #482) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/529
* fix(cli): list --version in help and error footers (Fixes #511) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/532
* refactor(cli): single holding-scope owner for option defaults, delete legacy scan by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/530
* fix(cli): report unknown root flag as UnknownOption on abstract command (Fixes #508) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/534
* fix(cli): mark required options and suppress phantom default (Fixes #507) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/533
* fix(cli): gate reserved help-word =-forms and --no-help as InvalidValue by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/531
* fix(cli): valued --no-<name> remedy omits failing bare form (root cause: unguarded IsFlag suggestion) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/536
* fix(cli): reserve help/version shorts (Fixes #499) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/535
* fix(cli): help beats missing required, footer points at working help by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/537
* fix(cli): require subcommand for abstract root commands by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/538
* fix(cli): abstract root reports InvalidValue for negated valued option by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/540
* fix(cli): abstract root reports InvalidValue for positive =-form flag literal (Fixes #542) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/544
* fix(cli): pin positional arguments leaf-local (Fixes #543) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/546
* fix(cli): suppress did-you-mean self-echo on exact surplus token (Fixes #541) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/545
* chore: comment-jargon cleanup plus approved test-log deletions by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/547
* fix: resolve XML doc warnings (CS1570/CS1574) by @Kiryuumaru in https://github.com/Kiryuumaru/ApplicationBuilderHelpers/pull/548

**Full Changelog**: https://github.com/Kiryuumaru/ApplicationBuilderHelpers/compare/build.20260917103104.6134f4f...build.20260923094141.73156fb