Provide a clearer error message when dotnet-install-tool fails because of incorrect package type
See original GitHub issueSteps 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 https://github.com/aspnet/DotNetTools/issues/399 and https://github.com/aspnet/Announcements/issues/290#issuecomment-369015372
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:9 (6 by maintainers)
Top GitHub Comments
For reference, here’s what’s currently displayed for preview2 (master):
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.
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