Search code examples
c#.netvisual-studionugetvisual-studio-2017

ASP.NET - "Data at the root level is invalid" error while browsing Nuget Packages in VS 2017


I'm trying to create a .NET Web API Application and install EntityFramework using Nuget Package Manager.

But when I'm going to : Right Click on Project References > Manage Nuget Packages > Browse I can't find Microsoft.EntityFrameworkCore in the list.

Then I'm having this error showing at the bottom, in the output section :

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

I use VS 2017 15.5.2 and .Net Framework 4.7.02556.

I also get this error when using the dotnet cli command 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.

It looks like that the dotnet cli is trying to load the remote index.json file as a XML file.

For your information, dotnet --version is showing 2.1.3.

Any idea?


Solution

  • It looks like the error came from the %appdata%/Roaming/NuGet/NuGet.Config file There was no syntax error in this file but I just deleted it and reopened VS 2017 that created another NuGet.Config with less data than the deleted one. Then the error disappeared.