Cannot install dotnet-ef tool on Windows 10
Asked Answered
A

9

36

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 
Arctogaea answered 8/11, 2019 at 10:1 Comment(1)
you can try nuget package manager consoleCloth
A
59

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

Arctogaea answered 8/11, 2019 at 10:16 Comment(5)
There is a closed issue report on it here: github.com/dotnet/EntityFramework.Docs/issues/2044Rapier
FYI: 3.0.0 is the version of dotnet-efHerv
Note that this is an old version of dotnet-ef. Current is 5.0.5.Centralization
Why is this the case, having to directly specify the version?Dacron
I'm using dotnet 6 and windows 11 but still dosen't work. <b>Command:</b> dotnet tool install --global dotnet-ef --version 6.0.4Oneway
P
25

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

Source

Possible answered 15/7, 2021 at 12:40 Comment(1)
Thanks a lot : best answer. With other commands, I had to uncheck custom package source before running commands. The parameter "--ignore-failed-sources" fix everything.Cirrus
P
4

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.

Phooey answered 10/8, 2021 at 8:54 Comment(1)
This fixed it for me and I'm using Windows 10. I had to right click my project -> Manage NuGet Packages, then in the top right next to "Package Source" I clicked on the settings cogwheel symbol and made sure only nuget.org and Microsoft Visual Studio Offline Packages were selected.Handshake
I
4

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.

Invertase answered 13/7, 2022 at 17:19 Comment(0)
S
2

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"
Sporting answered 18/5, 2023 at 13:21 Comment(2)
Why would that succeed if just installing it from NuGet wouldn't? BTW, the link is incorrect.Leucoplast
For some reason in my case it couldn't be installed from the web. There may be some kind of network problem on the corporate network. I had to download the package and install from a local folder. Yes the link is broken. My faultTreatment
P
0

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.

Portmanteau answered 25/3, 2020 at 10:35 Comment(0)
M
0

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

Microspore answered 23/3, 2021 at 14:0 Comment(0)
F
0

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

Falsehood answered 22/2, 2022 at 4:46 Comment(0)
D
0

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.

Disunion answered 11/7 at 20:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.