Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I found invalid data while decoding error updating NuGet packages

I have been trying to update NuGet packages in Visual Studio 2019 from both package manager consoles and the manage NuGet packages from the context options, but in both cases I get "Found invalid data while decoding." error.

I have to revert to Visual Studio 2017 to update. Is there a way to deal with this or do I have to contend with this switching for now?

The error outputs are as below for both scenarios:

Enter image description here

like image 354
xariez Avatar asked Apr 23 '19 08:04

xariez


People also ask

How do I fix a missing NuGet package?

Enable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages. In Solution Explorer, right click the solution and select Restore NuGet Packages.

How do I force a NuGet package to reinstall?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.

How do I update NuGet with latest version?

Right-click the Packages folder in the project, and select Update. This will update the NuGet package to the latest version. You can double-click the Add packages and choose the specific version.


2 Answers

Visual Studio 2019

  1. Go to menu ToolsNuGet Package ManagerPackage Manager Console.
  2. Type dotnet nuget locals all --clear.
  3. Clean the solution.
  4. Delete the bin and obj folders from the project folder.

It is 100% working.

like image 177
CThru Avatar answered Oct 10 '22 13:10

CThru


Deleting the obj and bin folders in each project in my solution, then reopening Visual Studio 2019 to trigger automatic package download worked for me. I don't think you need to remove bin as well but I was going crazy at that point.

like image 25
Tim Avatar answered Oct 10 '22 14:10

Tim