sdfsd
sdfsd

Reputation: 1213

Cannot install dotnet-ef tool on Windows 10

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

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

I gives me the following error:

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 Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

I'm using dotnet 3.0, I believe I didn't have this problem on MacOS, I'm now trying to execute the same command on my Windows 10 machine and it gives me that error.

Some info using dotnet --info command:

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download 

Upvotes: 38

Views: 39482

Answers (9)

FoxDeploy
FoxDeploy

Reputation: 13567

For an easy, one-step fix to this, try this command:

 dotnet tool install dotnet-counters --interactive --ignore-failed-sources --add-source https://api.nuget.org/v3/index.json

I found that the reason for the failure was very often a 401 unauthorized error, not being shown to the user.

The combination of --interactive will prompt for credentials if expired, while the -add-source instructs the dot net tool to look as well to a mainline package stream of nuget.org.

Upvotes: 0

My way of dealing with this problem was that I downloaded the package directly from package source

and then specified an alternative source in the command

dotnet tool install --global dotnet-ef --version 7.0.2 --add-source "C:\nuget"

Upvotes: 2

Pepe Alvarez
Pepe Alvarez

Reputation: 1634

If everything else failed then you should check in your Visual Studio the next route: Tools > NuGet Package Manager > Package Manager Settings > Nuget Package Manager > Package Sources. There you should have nuget.org, if not and you only have Microsoft Visual Studio Offline Packages, well that is the problem. Next you need to add the package resource nuget.org like this: enter image description here

Once you click Ok you can go back to your terminal and install dotnet-ef with no problem.

Upvotes: 4

uopeydel
uopeydel

Reputation: 441

For some of reasons you can try to delete directory C:\Program Files\dotnet\sdk-manifests it will make you can download it.

.net 6 ref : https://github.com/dotnet/sdk/issues/23435

Upvotes: 0

Andrii Kuznietsov
Andrii Kuznietsov

Reputation: 41

I had the same issue on Mac OS recently. It was related to the fact that we use our own NuGet feed (packageSources section). So, I fixed that by removing the custom NuGet feed from NuGet.config file for a while.

Upvotes: 4

Paul
Paul

Reputation: 638

dotnet tool install -g dotnet-ef --ignore-failed-sources worked for me. Thanks to Anas-Alhariri

Source

Upvotes: 26

cdonner
cdonner

Reputation: 37718

I got this error when I tried to run the command from the Package Manager Console instead of a Powershell command window.

Upvotes: 0

Richard Garside
Richard Garside

Reputation: 89260

I got this error message, but when I closely inspected all the errors I also had:

Response status code does not indicate success: 407 (Proxy Authorization Required).

Turning off the proxy while running the command fixed the issue.

Upvotes: 0

sdfsd
sdfsd

Reputation: 1213

I got it working by adding the --version flag and specifying the version to 3.0.0.

The command that I used:

dotnet tool install --global dotnet-ef --version 3.0.0

Upvotes: 60

Related Questions