Skip to content

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

Closed
@natemcmaster

Description

@natemcmaster

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)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions