question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 https://github.com/aspnet/DotNetTools/issues/399 and https://github.com/aspnet/Announcements/issues/290#issuecomment-369015372

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
peterhuenecommented, 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.

1reaction
KathleenDollardcommented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Provide a clearer error message when dotnet-install-tool ...
dotnet install tool Microsoft.Dotnet.Watcher.Tools -g Install failed. Failed to download package: NuGet returned: Failed to restore package.
Read more >
c# - Error installing dotnet tool package because "it is not ...
I built my project successfully, but dotnet.exe on my computer still behaviors very strange and unstable, I mean sometimes project still not ...
Read more >
Troubleshoot .NET tool usage issues
Package ID incorrect​​ A common reason for failure is that the tool name isn't correct. This can happen because of mistyping, or because...
Read more >
.NET Core Global Tools and Gotchas
NET Core global tool package, and how to deal with the gotchas ... Users install tools by executing “dotnet install tool”:.
Read more >
Best practice with error messages say what is wrong, or ...
If a error is shown, explain what's wrong, and give suggestions. It's not one or the other, but both. I have answered a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found