Nuget 不安装包

Nuget not installing packages

目标

我的目标是通过 NuGet 包管理器简单地安装包。

我决定删除 Visual Studio 2019 并重新安装。希望它能解决我的问题。然后,我创建了一个新项目 - 尝试下载 Newtonsoft.Json 包并显示相同的错误。

错误

Severity    Code    Description Project File    Line    Suppression State
Error       The feed 'nuget.org [https://api.nuget.org/v3/index.json]' lists package 'Newtonsoft.Json.13.0.1' but multiple attempts to download the nupkg have failed. The feed is either invalid or required packages were removed while the current operation was in progress. Verify the package exists on the feed and try again.
Unable to find package 'Newtonsoft.Json.13.0.1'.                

我试过的

我尝试了以下解决方案:

再次显示同样的错误。

此外,已尝试安装另一个软件包,例如 Microsoft.Extensions.DependencyInjection

然后我查看了输出,显示如下:

  GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
  OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json 199ms
  GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/13.0.1/newtonsoft.json.13.0.1.nupkg
  OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/13.0.1/newtonsoft.json.13.0.1.nupkg 1ms
  GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/13.0.1/newtonsoft.json.13.0.1.nupkg
  OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/13.0.1/newtonsoft.json.13.0.1.nupkg 96ms
  GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/13.0.1/newtonsoft.json.13.0.1.nupkg
  OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/13.0.1/newtonsoft.json.13.0.1.nupkg 96ms
  GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
  OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json 498ms
  CACHE https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
  CACHE https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
The feed 'nuget.org [https://api.nuget.org/v3/index.json]' lists package 'Newtonsoft.Json.13.0.1' but multiple attempts to download the nupkg have failed. The feed is either invalid or required packages were removed while the current operation was in progress. Verify the package exists on the feed and try again.
  Unable to find package 'Newtonsoft.Json.13.0.1'.
Time Elapsed: 00:00:00.9643895

我也遵循了 Microsoft 网站 (Visual Studio 用户的快速解决方案) 的步骤:https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting

没有任何变化。

为什么我的 NuGet 包没有安装?

NuGet.Config

这就是我的 NuGet.Config 的样子。在 C:\Users\SomeUser\AppData\Roaming\NuGet.

中找到
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

这些是我为使它起作用而执行的步骤。

Tools > NuGet Package Manager > Package Manager Settings

进入Package Sources

复制nuget.org

的详细信息

删除nuget.org

然后,使用您复制的详细信息重新添加 nuget.org