Skip to content

Running "dotnet -v diag run" shows diagnostics but fails to run #7346

Closed

Description

@shanselman

Steps to reproduce

C:\Users\scott\Desktop\newdotnet\src\project1> dotnet -v diag run
Telemetry is: Enabled
projetfactory: MSBUILD_EXE_PATH = C:\Program Files\dotnet\sdk\1.0.0-preview4-004233\MSBuild.dll
projetfactory: MSBuild project path = C:\Users\scott\Desktop\newdotnet\src\project1\project1.csproj
projecttoolscommandresolver: resolving commandspec from 0 Tool Libraries.
projecttoolscommandresolver: failed to resolve commandspec from library.
Microsoft.DotNet.Cli.Utils.CommandUnknownException: No executable found matching command "dotnet-diag"
   at Microsoft.DotNet.Cli.Utils.Command.Create(ICommandResolverPolicy commandResolverPolicy, String commandName, IEnumerable`1 args, NuGetFramework framework, String configuration, String outputPath, String applicationName)
   at Microsoft.DotNet.Cli.Utils.Command.Create(String commandName, IEnumerable`1 args, NuGetFramework framework, String configuration, String outputPath, String applicationName)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

Expected behavior

Note that the diagnostics shows indicating that -v got the "diag" switch but then it tries to run dotnet-diag.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview4-004233)

Product Information:
 Version:            1.0.0-preview4-004233
 Commit SHA-1 hash:  8cec61c6f7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14986
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0-preview4-004233

Activity

  1. livarcocc commented on Dec 14, 2016

    @livarcocc
    Contributor

    @shanselman the problem here is that we have two -v flags that indicate verbosity. The -v passed before the command (run, build, restore, publish, etc) is used by the CLI itself for its own verbosity and it does not expect a parameter. Because of that, the command line parser assumes that diag is the command and run a parameter to it.

    If you want to set the verbosity to msbuild, you need to pass the -v after the command name, like dotnet run -v diag (which won't have verbosity on the CLI itself). Or dotnet -v run -v diag.

    @blackdwarf Maybe we should change one of these flags so that this does not happen.

  2. shanselman commented on Dec 14, 2016

    @shanselman
    ContributorAuthor

    Ya that's totally confusing. I would assume that "outer" params would be for dotnet.exe and "inner" ones would be for the command. So:

    dotnet -foo run -foo

    Would send the first one to dotnet.exe and the rest to the run command.

  3. TheRealPiotrP commented on Dec 14, 2016

    @TheRealPiotrP

    Our convention for passing stuff to the application being run is dotnet run -foo -- -foo, where -- separates arguments to the command from arguments to the app.

    dotnet -foo run is not exactly what we want because it implies that -foo is being passed to dotnet itself, which is not the case unless we want to configure the host itself [e.g. dotnet --fx-version 1.0.0-preview6 run --foo. The options/arguments for runneed to come to the right ofrun`. The arguments to the app need to come to the right of that.

    We can certainly brainstorm other conventions, but there is an intent in the current implementation. We either need to better communicate that intent or we need to change it while accounting for the remaining scenarios.

  4. shanselman commented on Dec 14, 2016

    @shanselman
    ContributorAuthor

    Forgive my ignorance, but is that - and -- thing a convention anywhere? Is that "a thing?"

    Honestly, I'm sitting here reading your comment over and over and I'm still not sure which is which. I suspect that this isn't discoverable (unless I do learn that this is a standard *nixism)

    I thought what I said made more sense and was similar to what you're saying. arguments to dotnet come to the right of dotnet but before the command, and arguments to the command come to the right of the first command.

  5. thesmithee commented on Dec 14, 2016

    @thesmithee

    I'm not sure I'm following the thread of discussion. So, here is my take:

    • The arguments immidiatelly following dotnet will be sent to the muxer
    • The arguments following the verb will be sent to the verb
    • In case of dotnet run, the -- is used as a separator to make it clear that whatever follows -- is for the application that dotnet run is running; I believe this is something that exists in GNU standards
    • Yes, it is confusing to have two -v options in there. Since the muxer is 0 or 1 and doesn't have verbosity levels, we could change it to be -d|--diagnostics.
    • The short/long form of parameters are very much a UNIX "thing", so much so, that many CLI toolsets and apps out there behave the same way; I do believe that we are using the GNU modification of the POSIX standard for these in the CLI

    /cc @schellap for the muxer change of the option since he would do the work should we do it.

    Hope this makes sense. The original issue would be resolved by renaming the muxer option since it would be clear it is different from the rest of the CLI verbs' --verbosity option.

  6. schellap commented on Dec 14, 2016

    @schellap

    @blackdwarf If the muxer understands arguments like --sdk-version for example, it will filter those until the first unknown argument. Starting from the first unknown argument, everything will pass on to the CLI command parser to be dealt with. It won't be in the business of understanding what is verb and what is option etc. (ex: dotnet --sdk-version "1.2.0" --info)

  7. thesmithee commented on Dec 14, 2016

    @thesmithee

    @schellap fully understand that. One dimension of the issue here is that we have two very similarly named options that are different in behavior. The user comes in, sees that there is a way to provide verbosity to the muxer, assumes that it can take the same verbosity levels as other commands (after all, it is all MSBuild-bsed now, right?) and an error comes up. That is not good UX.

    That part can be solved by simply renaming the muxer option to something that would not induce confusion and put users on the wrong path.

  8. schellap commented on Dec 14, 2016

    @schellap

    @blackdwarf

    The user comes in, sees that there is a way to provide verbosity to the muxer, assumes that it can take the same verbosity levels as other commands

    Btw, there is no verbosity for the muxer or a -v option at all. The -v has been around even before the muxer and is used for logging when CLI shells out to other commands. The muxer verbosity is through the environment variable COREHOST_TRACE.

    But, I think the issue here is slightly different. It is passing -v to the app under run vs. passing -v to the CLI itself. The following ordering needs to be clearly documented.

    To execute a command, use dotnet command (ex: dotnet run)
    To debug or enable logging for the command, use dotnet -v command (ex: dotnet -v run)
    To pass arguments to application being run, use dotnet run --app-args (ex: dotnet run -v diag)

    dotnet -v run -v diag, this follows from above.

    I think it needs to be better documented or the UX could be better. Also, there are many actors: dotnet.exe (--sdk-version), dotnet CLI (-v), dotnet run (--arg before the --), app (-v diag) all consume arguments.

  9. thesmithee commented on Dec 14, 2016

    @thesmithee

    @schellap thanks for the info. slightly_smiling_face: This changes my suggestion above insofar as the potential change is not in the muxer (and the fact that not all options preceeding the verb are muxer options) but in dotnet.dll. I still think that dotnet -v run -v diag is not super clear.

    For dotnet run, we already have a convention that -- is used to disambiguate between verb's and app's arguments. But yeah, your other point is good, there needs to be crisp documentation on this as part of https://docs.microsoft.com/en-us/dotnet/articles/core/tools/index. Can you file an issue for this on dotnet/docs and /cc me?

  10. thesmithee commented on Dec 15, 2016

    @thesmithee

    OK, I think we should use this issue to rename the -v | --verbosity to -d | --diagnostics to allow differentiation. As chatted offline @livarcocc I'm assigning this to you.

  11. transferred this issue fromdotnet/clion Jan 31, 2020
  12. added this to the 1.0.0-preview5 milestone on Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions