问题
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?
回答1:
- Make sure you upgrade to the latest NuGet (http://docs.nuget.org/docs/start-here/installing-nuget).
- 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.
回答2:
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.
回答3:
I had a similar issue with the Microsoft.Bcl.Build.1.0.14
NuGet package. My solution to this was to
- Close Visual Studio
- Remove the package folder with Explorer (or better only move it to another location)
- Start Visual Studio
- Go to the NuGet package manager and click Restore
回答4:
This is how I fix my issue:
First I clear my Package Source:
Then second, make sure I have the right path source and click the available package source:
回答5:
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
回答6:
(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.
回答7:
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
回答8:
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>
...
回答9:
Go to TOOLS under OPTIONS select NuGet Package Manager
- General, Select Everything
- Package Source, Select all required Source
Hit OK. Done you must be good to go.
来源:https://stackoverflow.com/questions/22153474/an-error-occurred-while-trying-to-restore-packages-please-try-again