Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a clearer error message when dotnet-install-tool fails because of incorrect package type #9122

Closed
natemcmaster opened this issue Feb 28, 2018 · 9 comments
Assignees
Labels
Milestone

Comments

@natemcmaster
Copy link
Contributor

Steps to reproduce

dotnet install tool Microsoft.Dotnet.Watcher.Tools -g

Expected behavior

A message that explains the package clearly what is wrong. Maybe:

This package does not support installation as a global command line tool because it does not have the correct package type in its metadata. See https://aka.ms/something for details on requirements for command line tool packages.

Actual behavior

You get a wall of text. The error message does not clearly indicate what went wrong.

> dotnet install tool Microsoft.Dotnet.Watcher.Tools -g
Install failed. Failed to download package:
NuGet returned:

Failed to restore package.
WorkingDirectory:
Arguments: restore C:\Users\scott\AppData\Local\Temp\gnzjrzwo.bvk\nh3id1v4.onz.csproj --runtime win10-x64 /p:BaseIntermediateOutputPath=\"C:\Users\scott\.dotnet\toolspkgs\Microsoft.Dotnet.Watcher.Tools\2gtgbll5.42m\"
Output:   Restoring packages for C:\Users\scott\AppData\Local\Temp\gnzjrzwo.bvk\nh3id1v4.onz.csproj...
  Installing Microsoft.NETCore.DotNetAppHost 2.0.0.
  Installing Microsoft.NETCore.DotNetHostResolver 2.0.0.
  Installing NETStandard.Library 2.0.0.
  Installing Microsoft.NETCore.Platforms 2.0.0.
  Installing Microsoft.NETCore.DotNetHostPolicy 2.0.0.
  Installing Microsoft.NETCore.App 2.0.0.
  Installing Microsoft.DotNet.Watcher.Tools 2.0.0.
  Installing runtime.win-x64.Microsoft.NETCore.DotNetAppHost 2.0.0.
  Installing runtime.win-x64.Microsoft.NETCore.DotNetHostResolver 2.0.0.
  Installing runtime.win-x64.Microsoft.NETCore.DotNetHostPolicy 2.0.0.
  Installing runtime.win-x64.Microsoft.NETCore.App 2.0.0.
C:\Users\scott\AppData\Local\Temp\gnzjrzwo.bvk\nh3id1v4.onz.csproj : error NU1212: Invalid project-package combination for Microsoft.DotNet.Watcher.Tools 2.0.0. DotnetToolReference project style can only contain references of the DotnetTool type
  Restore failed in 5.89 sec for C:\Users\scott\AppData\Local\Temp\gnzjrzwo.bvk\nh3id1v4.onz.csproj.

The error message is

Invalid project-package combination for Microsoft.DotNet.Watcher.Tools 2.0.0. DotnetToolReference project style can only contain references of the DotnetTool type

I don't think this error makes it clear to users why the package could not be installed.

Environment data

dotnet --version: 2.1.300-preview1-008174

cc @wli3 @KathleenDollard @shanselman

cref aspnet/DotNetTools#399 and aspnet/Announcements#290 (comment)

@wli3
Copy link

wli3 commented Feb 28, 2018

One of the decision is let nuget error pass through and cli will not do further "translation". @KathleenDollard @peterhuene @livarcocc in this case we should ask nuget to have better error message do you agree?

@KathleenDollard
Copy link

We had some internal discussion of this, and decided that failing to pass the NuGet message through crippled certain debugging scenarios. Specifically, if a package can't be found, knowing which package is to found is helpful.

Yes, it is painful here and it is going to be an easy mistake to make.

Let's take another quick look at this

@shanselman
Copy link
Contributor

shanselman commented Feb 28, 2018

Thanks! I feel that dotnet.exe is quickly becoming (and should be considered) a first line "User Interface" so I'd love to see less logging and stack traces and more "pit of success" messages.

And just like we do 301 redirects for URLs to make sure there's a canonical one, for fundamental packages like this that move or rename, we want to make sure that the end result is that the user has the commands available to them. For me, that meant removing the old CliTool from the csproj manually, and then manually installing the new dotnet-watch package (which I understand will become global automatically (?) in preview2.

@peterhuene
Copy link
Contributor

peterhuene commented Feb 28, 2018

For reference, here's what's currently displayed for preview2 (master):

$ dotnet install tool Microsoft.Dotnet.Watcher.Tools -g
/var/folders/rl/m1rv1rxd643gpwspqrbxy76r0000gn/T/w1heen5l.wc5/yh505uu5.u4i.csproj : error NU1212: Invalid project-package combination for Microsoft.DotNet.Watcher.Tools 2.0.0. DotnetToolReference project style can only contain references of the DotnetTool type
The tool package could not be restored.
Tool 'Microsoft.Dotnet.Watcher.Tools' failed to install.

Still using the same error coming from NuGet which is not clear, but the format is a little less verbose. I'd love to see us at least remove the project file out of the error message.

@peterhuene
Copy link
Contributor

peterhuene commented Feb 28, 2018

I've filed dotnet/cli#8707 to at least remove the temp project from the error message since it is entirely unhelpful and only contributes to a worse diagnostic experience. We'll file an issue with NuGet to see if we can improve the underlying error message when requested package type isn't a "tool".

@KathleenDollard
Copy link

KathleenDollard commented Mar 1, 2018

I have filed NuGet/Home#6630 to work on the text. Without that fix from NuGet and with dotnet/cli#8707, the experience would be

$ dotnet install tool Microsoft.Dotnet.Watcher.Tools -g
error NU1212: Invalid project-package combination for Microsoft.DotNet.Watcher.Tools 2.0.0. DotnetToolReference project style can only contain references of the DotnetTool type
The tool package could not be restored.
Tool 'Microsoft.Dotnet.Watcher.Tools' failed to install.

With my suggestion for the NuGet fix (open for better language, please comment in the NuGet issue)

$ dotnet install tool Microsoft.Dotnet.Watcher.Tools -g
error NU1212:  The requested package does not have the expected DotnetTool type and can't be used where that type is expected. For example, this package can't be used with "dotnet install tool -g".
The tool package could not be restored.
Tool 'Microsoft.Dotnet.Watcher.Tools' failed to install.

@natemcmaster and others: Do you think this solves this problem?

@natemcmaster
Copy link
Contributor Author

Yeah, I think that would work.

@peterhuene
Copy link
Contributor

@livarcocc Do we need this held open? The NuGet issue Kathleen opened is where the real fix needs to happen and dotnet/cli#8707 has already been fixed.

@peterhuene
Copy link
Contributor

peterhuene commented Mar 23, 2018

Now that the other clean-up work is in for the tool install UX, I'm going to close this issue in favor of NuGet/Home#6630 that is the remaining piece of the puzzle (a clearer message that the package that was found was not a tool package and cannot be installed with dotnet tool install).

Please re-open this issue if you feel like Kathleen's suggested fix above is an insufficient UX. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants