dotnet tool install --global dotnet-ef 失败原因及解决办法

给.net core 3.1.1安装ef时报错,如下

-> dotnet tool install --global dotnet-ef
error NU1100: Unable to resolve 'dotnet-ef ' for '.NETCoreApp,Version=v3.1'.
error NU1100: Unable to resolve 'dotnet-ef ' for '.NETCoreApp,Version=v3.1/any'.
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.

网上找了半天,终于找到解决办法:

https://stackoverflow.com/questions/54785951/unable-to-install-packages-using-dotnet-add-package/54798770#54798770

1. 将C:\Users\<user>\AppData\Roaming\NuGet文件夹下的NuGet.Config删除

2.在项目文件夹下运行命令:dotnet restore。将会生成新的NuGet.Config文件,其中packageSources的值不同,旧的为https://www.nuget.org/api/v2/

新的为

https://api.nuget.org/v3/index.json

正是这个差异导致相关下载失败。

之后再运行相关命令行就可以正常下载了。

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值