I found invalid data while decoding error updating NuGet packages
10,733
Solution 1
Visual Studio 2019
- Go to menu Tools → NuGet Package Manager → Package Manager Console.
- Type
dotnet nuget locals all --clear
. - Clean the solution.
- Delete the
bin
andobj
folders from the project folder.
It is 100% working.
Solution 2
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.
Related videos on Youtube
![xariez](https://i.stack.imgur.com/EmPVn.jpg?s=256&g=1)
Comments
-
xariez over 1 year
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:
-
Richard about 5 yearsClear your local NuGet cache? (See here for details.)
-
xariez about 5 years@Richard still not helpful even after clearing cache
-
cjcrobin about 5 yearsI found this could be a VS 2019 issue, and temporarily I make it work by removing obj folder and clearing all the cache.
-
Greesemonkey3 almost 5 yearscjcrobin's comment above worked! I cleared the NuGet cache then after deleting the obj folder it worked.
-
-
Martin Lottering about 4 yearsI had to do this twice, the second time I was more patient and let Visual Studio start-up and take its time to initialize completely before building. If you started a Clean or Build and Visual Studio seems like it is hanging, you can cancel the Build from the Build menu and then from the Visual Studio task list, in the bottom-left corner task list.
-
ModestMonk almost 4 yearsSo many other posts and none of them worked. Thank you so much. This is why I hate admins that delete duplicate questions. That 'duplicate' question has slight differences that ultimately had different answers. This is exactly what I needed!
-
silencej almost 4 yearsTrying clicking every button in VS2019 ends into nothing helpful. Kind of curious how one can find the secret command line and save the world spoiled by GUI. It's so hard to find the info in Windows doc, but SO is the save.
-
Daiana Sodré almost 4 yearsThank you very much! After 3 hours trying to solve this problem, i finally found your solution!
-
Jesper Mygind over 2 yearsAlso works in Visual Studio 2022
-
Sunny Tambi over 2 yearsWorked like a charm .. thanks
-
Eli Gassert about 2 years
dotnet nuget locals all --clear
also fixed issueerror : '.', hexadecimal value 0x00, is an invalid character. Line 1, position 1.
Adding for search engine juice. I encounted this error when I was trying to use WSL / ubuntu and trying to usedotnet build
. Thanks!