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

前端 未结 10 1040
遇见更好的自我
遇见更好的自我 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:

      <Reference Include="Xxx, Version=30.0.0.16927, Culture=neutral, processorArchitecture=MSIL">
          <HintPath>..\packages\Xxx.35.1.122605\lib\net461\Xxx.dll</HintPath>
      </Reference>
      
    • 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:

      <package id="Xxx" version="35.1.122605" targetFramework="net461" />
      
    • 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 :)

    0 讨论(0)
  • 2020-12-16 10:35

    Go to TOOLS under OPTIONS select NuGet Package Manager

    1. General, Select Everything
    2. Package Source, Select all required Source

    Hit OK. Done you must be good to go.

    0 讨论(0)
  • 2020-12-16 10:38

    I resolved the same issue by downloading the latest version of NuGet (really easy install, quick download): http://docs.nuget.org/docs/start-here/installing-nuget

    0 讨论(0)
  • 2020-12-16 10:41

    This is how I fix my issue:

    First, I clear my Package Cache:

    Second, I make sure I have the right path source and click the available package source:

    0 讨论(0)
提交回复
热议问题