dotnet / dotnet/command-line-api

UseHost() - Can't assign HelpAction() to root command or synchronous action to any command

Open
#2,221 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

In my app want to set the action of the root command to a HelpAction to display help if no subcommand is specified. This worked until the PR to split actions into Async and Sync. If any command actions were synchronous then this will throws as well with unable to cast SynchronousAction to AsynchronousAction.

Unable to cast object of type 'System.CommandLine.Help.HelpAction' to type 'System.CommandLine.Invocation.AsynchronousCliAction'.
System.InvalidCastException: Unable to cast object of type 'System.CommandLine.Help.HelpAction' to type 'System.CommandLine.Invocation.AsynchronousCliAction'.
at System.CommandLine.Hosting.HostingAction.SetHandlers(CliCommand command, Func`2 hostBuilderFactory, Action`1 configureHost)
at System.CommandLine.Hosting.HostingExtensions.UseHost(CliConfiguration builder, Func`2 hostBuilderFactory, Action`1 configureHost)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.