【问题标题】:dotnet tool install --global dotnet-ef --version 3.0.0 on MAC causes unknown Nuget ErrorMAC 上的 dotnet tool install --global dotnet-ef --version 3.0.0 导致未知 Nuget 错误
【发布时间】:2019-12-11 09:51:46
【问题描述】:

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

dotnet ef

得到:

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.

然后找到了这个 - dotnet ef not found in .NET Core 3

因此,尝试了:

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

得到:

/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: ...

如何解决?

【问题讨论】:

    标签: .net-core ef-core-3.0


    【解决方案1】:

    找到这个 -

    Nuget connection attempt failed "Unable to load the service index for source"

    所以,然后在 MAC 上打开 Nuget.config -

    ~/.nuget/Nuget/Nuget.config
    

    并从那里删除所有网址。

    重新运行

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

    工作:)

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

    <configuration>
        <packageSources>
            <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
        <packageSources>
    </configuration>
    

    终于实现了使用ef tools 3.0.0,所以用-完成了ef tools的更新

    dotnet 工具更新--global dotnet-ef

    【讨论】:

    • 对于Windows VS2019,你可以这样做:工具|选项 | nuget 包管理器|包源 UI 取消选中/禁用该包源
    猜你喜欢
    • 2022-01-08
    • 2022-08-05
    • 2021-07-20
    • 1970-01-01
    • 1970-01-01
    • 2021-09-01
    • 1970-01-01
    • 2020-01-24
    • 2021-10-04
    相关资源
    最近更新 更多