Skip to content

Proposal: UseSystemCommandLine extension for IHostBuilder #2688

@pschmerling

Description

@pschmerling

Hi team,

while building .NET apps (console, WPF, Windows-Service) on top of System.CommandLine, I often combine it with Microsoft.Extensions.Hosting.
Today each app must:
• parse args manually,
• inject ParseResult into DI,
• handle --help / validation,
• wire optional post-parse configuration.

I propose a small host extension:

Host.CreateDefaultBuilder(args)
    .UseSystemCommandLine(rootCommand, args, (parseResult, services) =>
    {
        // optional post-parse configuration
    });

Benefits:
• Unified startup for console, WPF and service apps
• Single parse before building the host
• DI-friendly access to ParseResult or a typed accessor

This would live as an additive helper, so no breaking change.

Would you consider such an addition?
I’m happy to draft a PR if the idea fits the roadmap.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions