ASP.NET - 在 VS 2017 中浏览 Nuget 包时出现“根级别的数据无效”错误

Jer*_*e P 4 .net c# visual-studio nuget visual-studio-2017

我正在尝试创建 .NET Web API 应用程序并使用 Nuget Package Manager 安装 EntityFramework。

但是当我要执行以下操作时:右键单击“项目引用”>“管理 Nuget 包”>“浏览”,我在列表中找不到Microsoft.EntityFrameworkCore 。

然后我在输出部分的底部显示此错误:

[nuget.org] Data at the root level is invalid. Line 1, position 1.

我使用VS 2017 15.5.2.Net Framework 4.7.02556

使用dotnet cli命令 时我也收到此错误dotnet add package Microsoft.EntityFrameworkCore

error: The content at 'https://api.nuget.org/v3/index.json/FindPackagesById()?id='Microsoft.EntityFrameworkCore'' is not valid XML. error: Data at the root level is invalid. Line 1, position 1.

看起来 dotnet cli 正在尝试将远程 index.json 文件作为 XML 文件加载。

供您参考,dotnet --version正在显示2.1.3.

任何想法?

小智 12

使用 VS 2019,我的解决方案是清除所有 NuGet 缓存

这可以通过选项 -> NuGet 包管理器 -> 常规 -> 清除所有 NuGet 缓存来实现。