无法添加或更新 NuGet 包,收到 NuGet V2 提要错误

Cannot add or update NuGet packages, receiving NuGet V2 feed error

我最近转移到 VS 2019,现在我无法通过 NuGet 安装或更新包。我收到以下错误 -

An error occurred while retrieving package metadata for 'jQuery.3.4.1' from source 'NuGet.org'.
Failed to fetch results from V2 feed at 'https://www.nuget.org/FindPackagesById()?id='jQuery'&semVerLevel=2.0.0' with following message : Response status code does not indicate success: 404 (Not Found).
Response status code does not indicate success: 404 (Not Found).

我有指向 --- https://api.nuget.org/v3/index.json

的 NuGet 包源

我应该使用其他包源吗?

如果你在 VS 中遇到这个问题IDE:

Tools=>Nuget Package Manager=>Package Manager Settings=>Package Source查看是否有URL为https://www.nuget.org的其他包源,如果存在,disable/delete此包源。

如果您在命令行中遇到此问题:

您需要像这样指定来源:nuget install PackageName -Source https://api.nuget.org/v3/index.json -Version 3.4.1。您可以使用其他安装命令(dotnet 其他什么),只需确保在命令中指定正确的源即可。

希望能对解决问题的正确方向有所帮助:)

在 VS Package Sources 中,我有类似 http://api.nuget.org 的东西 我将其替换为 https://api.nuget.org/v3/index.json 并修复了它。 (把明确的版本号放在最后是行不通的。)