Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install anything using dotnet tool install command

I'm trying to install the dotnet-ef tool via the dotnet-cli.

The command that I enter: dotnet tool install --global dotnet-ef

It gives me the following error:

   C:\Users\%USERNAME%\AppData\Local\Temp\147383a8-b714-4336-bb96-30c0670ea37d\restore.csproj : error NU1211: Project res
tore must have a single package reference(s).
C:\Users\abby.rahimi\AppData\Local\Temp\147383a8-b714-4336-bb96-30c0670ea37d\restore.csproj : error NU1212: Invalid pro
ject-package combination for Microsoft.DotNet.Analyzers.Compatibility 0.2.12-alpha. DotnetToolReference project style c
an only contain references of the DotnetTool type
The tool package could not be restored.
Tool 'dotnet-ef' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

its not just about ef, I cant install any other tool.

I tried specifying version, still not working I tried a bunch of things:

  • dotnet tool install -g dotnet-ef --ignore-failed-sources
  • reinstalling dotnet sdks (3.1 and 6.0.305)
  • dotnet tool uninstall --global dotnet-ef and then tried to install again
  • removed executable dotnet-ef.exe from C:\Users%USERNAME%.dotnet\tools
  • run command in both power shell and win cli

I have an acces to https://api.nuget.org/v3/index.json so it's not the problem with my internet connection.

like image 536
Abby Avatar asked Feb 17 '26 00:02

Abby


1 Answers

it looks like dotnet tool iterates the nuget.config sources and when one fails, it doesn't continue with next ones.

In my case, it was failing because I have a private feed, which needs authentication (despite that configured in nuget.config).

Thanks to @wli3 who mentioned use of: --ignore-failed-sources like this:

dotnet tool install -g nbgv --ignore-failed-sources

Which did helped. Original link: https://github.com/dotnet/sdk/issues/16215#issuecomment-791796542

like image 139
Martin Kunc Avatar answered Feb 18 '26 12:02

Martin Kunc