关于.net core:dotnet工具在MAC上安装–global dotnet-ef –version 3.0.0导致未知的Nuget错误

 2021-04-27 

dotnet tool install --global dotnet-ef --version 3.0.0 on MAC causes unknown Nuget Error

在我的Web API项目中升级到.Net Core 3.1之后,我尝试了这个通常的ef命令-a€

1
dotnet ef

得到:

1
2
3
4
5
6
Could not execute because the specified command or file was not found.

Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET Core program, but dotnet-ef does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

然后发现了这一点-在.NET Core 3中找不到dotnet ef

因此,尝试:

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

并得到:

1
2
3
4
/usr/local/share/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v2/index.json
/usr/local/share/dotnet/sdk/3.1.100/NuGet.targets(123,5): error :   Response status code does not indicate success: 400 (Bad Request).
The tool package could not be restored.
Tool 'dotnet-ef' failed to install. This failure may have been caused by: ...

如何修复?


找到了--

Nuget连接尝试失败"无法加载源的服务索引"

因此,然后在MAC上打开Nuget.config-

1
~/.nuget/Nuget/Nuget.config

并从其中删除所有URL。

重新运行

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

工作过:)

在VS for MAC项目中重新使用NUGET(只是添加了任何Nuget)时,我只剩下

1
2
3
4
5
<configuration>
    <packageSources>
       
    <packageSources>
</configuration>

最后,意识到使用了ef工具3.0.0,因此用-

完成了ef工具的更新。

dotnet工具更新--global dotnet-ef