I found invalid data while decoding error updating NuGet packages

10,733

Solution 1

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.

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.

Share:
10,733

Related videos on Youtube

xariez
Author by

xariez

Software Developer/Architecture Enthusiast

Updated on October 09, 2022

Comments

  • xariez
    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:

    Enter image description here

    • Richard
      Richard about 5 years
      Clear your local NuGet cache? (See here for details.)
    • xariez
      xariez about 5 years
      @Richard still not helpful even after clearing cache
    • cjcrobin
      cjcrobin about 5 years
      I found this could be a VS 2019 issue, and temporarily I make it work by removing obj folder and clearing all the cache.
    • Greesemonkey3
      Greesemonkey3 almost 5 years
      cjcrobin's comment above worked! I cleared the NuGet cache then after deleting the obj folder it worked.
  • Martin Lottering
    Martin Lottering about 4 years
    I 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
    ModestMonk almost 4 years
    So 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
    silencej almost 4 years
    Trying 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é
    Daiana Sodré almost 4 years
    Thank you very much! After 3 hours trying to solve this problem, i finally found your solution!
  • Jesper Mygind
    Jesper Mygind over 2 years
    Also works in Visual Studio 2022
  • Sunny Tambi
    Sunny Tambi over 2 years
    Worked like a charm .. thanks
  • Eli Gassert
    Eli Gassert about 2 years
    dotnet nuget locals all --clear also fixed issue error : '.', 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 use dotnet build. Thanks!