An error occurred while trying to restore packages. Please try again

前端 未结 10 1042
遇见更好的自我
遇见更好的自我 2020-12-16 09:45

I am trying to restore the missing nuget packages and it keeps giving me this Error:

An error occurred while trying to restore packages. Please try again.
         


        
10条回答
  •  既然无缘
    2020-12-16 10:33

    The problem in my case

    In my case, we have developed our own NuGet packages. For some indescribable reason when I opened the solution, When I open solution, that has a previous version of NuGet packages that is deleted from origin or removed or unreachable for any reason. This make it unable to build the projects containing specific NuGet packages. I tried to install/reinstall/upgrade the NuGet package with out luck getting following error (see the image below), I did also try all possible answers here, and ensured the package was there, but no luck.

    An error occurred while trying to restore packages: Unable to find version xxx..etc.

    The solution for my case

    • Close your solution and find the path of the solution

    • Open all your projects .csproj files with notepad editor, that contain the packages that have the issue and remove all references that is shown in the error message, looks like this and save:

      
          ..\packages\Xxx.35.1.122605\lib\net461\Xxx.dll
      
      
    • In each folder where your .csproj is located, you find packages.config file, open it with notepad editor and remove all packages that is shown in the error message, looks like this and save:

      
      
    • Start your solution, the error now should disappear, but you can not build because we have removed references and packages. So now you should be able to install your missing packages in fresh. When done build and all should work. Enjoy :)

提交回复
热议问题