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.
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.
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 :)
Go to TOOLS under OPTIONS select NuGet Package Manager
Hit OK. Done you must be good to go.
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
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: