Question

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.

Any experience solving this? How can I find out what exactly is causing the error?

Was it helpful?

Solution 2

  1. Make sure you upgrade to the latest NuGet (http://docs.nuget.org/docs/start-here/installing-nuget).
  2. Make sure you're doing package restore "The Right Way" http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

That should resolve the issue.

OTHER TIPS

This is how I fix my issue:

First, I clear my Package Cache:

enter image description here

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

enter image description here

If you don't want the package, just double-click your packages.config, find the line which refers to the package you want to get rid of, and delete that line.

Then, if you do want the package you could probably just redownload it using nuget and it'd probably resolve itself.

I had a similar issue with the Microsoft.Bcl.Build.1.0.14 NuGet package. My solution to this was to

  1. Close Visual Studio
  2. Remove the package folder with Explorer (or better only move it to another location)
  3. Start Visual Studio
  4. Go to the NuGet package manager and click Restore

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

(Definitely a beginner's answer here, but I'll leave it since I didn't find this anywhere else.) Make sure that nuget.org hasn't been unchecked from your package sources.

Tools. Options. Nuget package manager. Package sources. Ensure "nuget.org" is checked.

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.

enter image description here

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 :)

I had similar issue, i found out it was due to my nuget cache.

Command to clear cache: dotnet nuget locals all --clear

After cache is cleared try restoring.

i fix this problem by moving the project folder to another one with less characters (local path was to long) i hope it helps some one

For me I cloned a solution (vs2015/NuGet3.4) that had a nuget dependency on a pre-release package that had been superceded. Nuget failed to restore the pre-release and wouldn't let me either uninstall or upgrade it. I frigged it by manually editting packages.config to target an older non-pre-release of the package, which I could then upgrade to the version I wanted. HTH

Just in case it helps someone else, I had this issue in a .NET Standard project where I had defined the target frameworks incorrectly:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netstandard1.3;netstandard2.0;net45</TargetFramework>
    </PropertyGroup>
    ...

When it should have been the plural TargetFrameworks (not TargetFramework):

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFrameworks>netstandard1.3;netstandard2.0;net45</TargetFrameworks>
    </PropertyGroup>
    ...

For me non of those things mentioned above work. I solved this issue by deleting packages.config in each project of my solution and then reinstalling all Nuget packages

In my case, I had another package source added which was like this.

enter image description here

I just removed this source from the NuGet package manager and rebuild the solution, it started working for me.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top