dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.65k stars 1.06k forks source link

dotnet <command> -help or /help shows msbuild help #24868

Open nohwnd opened 2 years ago

nohwnd commented 2 years ago

Describe the bug

Calling dotnet <command> -help or dotnet <command> /help shows MSBuild help, and not <command> help. This is happening on build and test (and probably others). On run it gives no response, but also no error.

It would be nice if /Help and -help were handled in a consistent way, most likely by redirecting to the command help.

/? and -h both work as --help, and show the command help. MSBuild help suggests to use -? or -h, which will not show msbuild help, but instead will show the command help.

To Reproduce

Run dotnet build /help

Exceptions (if any)

There are none.

Further technical details

I am on 7.0.100-preview.4.22211.1

baronfel commented 2 years ago

This is a core tension between MSBuild and the .NET CLI, because many/most of its flags are not actually consistent with the CLI design principles that we try to adhere to in the .NET SDK, as documented here and here. Since the SDK merely wraps many of the third-party commands, those commands don't know that they're being hosted in a context that doesn't surface the same conventions as they do. This is a continuing point of integration pain.

For dotnet msbuild (meaning the command where we directly shim to the MSBuild command line), all of the SDK-style help invocations do delegate to MSBuild which I think is desired behavior. For the commands that the SDK wraps/customizes, though, the behavior is less clear. These commands wrap/transform on purpose, so I think the best approach might be to:

but I don't think that we should support /help or -help forms in the SDK, since they are non-standard. The single-flag form prevents the use of POSIX bundling of short-form arguments, and the / option prefix is a windows-specific idiom that we do not want to promote.

nohwnd commented 2 years ago

"/?" is also non-standard and it work, but I hear you 👍 Could the output append: "This is MSBuild help, if you wanted dotnet <command> help, please use dotnet <command> --help, -h"? With the <command> substituted?

baronfel commented 2 years ago

yeah, I agree that /? is non-standard, I want the System.CommandLine library to allow customizing the help option aliases specifically so we can remove it!

I think the follow-on text is an interesting idea - certainly doable!

nohwnd commented 2 years ago

Edited it, formatter ate my <command> place holders.