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 #8698

Closed
natemcmaster opened this Issue Feb 28, 2018 · 9 comments

Comments

Projects
None yet
6 participants
@natemcmaster
Copy link
Member

natemcmaster commented Feb 28, 2018

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

This comment has been minimized.

Copy link
Collaborator

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

This comment has been minimized.

Copy link

KathleenDollard commented Feb 28, 2018

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

@livarcocc livarcocc added this to the 2.1.3xx milestone Feb 28, 2018

@livarcocc livarcocc added the tool label Feb 28, 2018

@shanselman

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

peterhuene commented Feb 28, 2018

I've filed #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

This comment has been minimized.

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 #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

This comment has been minimized.

Copy link
Member

natemcmaster commented Mar 1, 2018

Yeah, I think that would work.

@peterhuene

This comment has been minimized.

Copy link
Member

peterhuene commented Mar 21, 2018

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

@peterhuene

This comment has been minimized.

Copy link
Member

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!

@peterhuene peterhuene closed this Mar 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment