[英]An error occurred while trying to restore packages. Please try again
I am trying to restore the missing nuget packages and it keeps giving me this Error:我正在尝试恢复丢失的 nuget 包,但它一直给我这个错误:
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?我怎样才能找出到底是什么导致了错误?
That should resolve the issue.那应该可以解决问题。
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.如果你不想要这个包,只需双击你的packages.config,找到你想要删除的包所在的那一行,然后删除那一行。
Then, if you do want the package you could probably just redownload it using nuget and it'd probably resolve itself.然后,如果您确实想要该软件包,您可能只需使用 nuget 重新下载它,它可能会自行解决。
I had a similar issue with the Microsoft.Bcl.Build.1.0.14
NuGet package.我在Microsoft.Bcl.Build.1.0.14
NuGet 包中遇到了类似的问题。 My solution to this was to我对此的解决方案是
我通过下载最新版本的 NuGet(非常容易安装,快速下载)解决了同样的问题: 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. (这里绝对是初学者的答案,但我会留下它,因为我没有在其他任何地方找到它。)确保 nuget.org 没有从您的包源中取消选中。
Tools.工具。 Options.选项。 Nuget package manager. Nuget 包管理器。 Package sources.包源。 Ensure "nuget.org" is checked.确保选中“nuget.org”。
In my case, we have developed our own NuGet packages.就我而言,我们已经开发了自己的 NuGet 包。
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.
出于某种
无法
描述的原因
,当我打开解决
方案时
,当我打开解决方案时,该解决方案具有从源中删除或删除或因任何原因无法访问的先前版本的 NuGet 包。 This make it unable to build the projects containing specific NuGet packages.这使其无法构建包含特定 NuGet 包的项目。 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.我尝试安装/重新安装/升级 NuGet 包,但不幸的是出现以下错误(见下图),我也在这里尝试了所有可能的答案,并确保包在那里,但没有运气。
An error occurred while trying to restore packages: Unable to find version xxx..etc.尝试恢复软件包时发生错误:无法找到版本 xxx.. 等。
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:使用记事本编辑器打开所有项目 .csproj 文件,其中包含有问题的包并删除错误消息中显示的所有引用,如下所示并保存:
<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:在 .csproj 所在的每个文件夹中,您会找到packages.config
文件,使用记事本编辑器打开它并删除错误消息中显示的所有包,如下所示并保存:
<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 :)享受 :)
我通过将项目文件夹移动到另一个字符较少的文件夹来解决这个问题(本地路径太长)我希望它对某人有所帮助
For me I cloned a solution (vs2015/NuGet3.4) that had a nuget dependency on a pre-release package that had been superceded.对我来说,我克隆了一个解决方案 (vs2015/NuGet3.4),该解决方案对已被取代的预发布包具有 nuget 依赖性。 Nuget failed to restore the pre-release and wouldn't let me either uninstall or upgrade it. Nuget 未能恢复预发行版,并且不会让我卸载或升级它。 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.我通过手动编辑 packages.config 以针对较旧的非预发布包来调整它,然后我可以将其升级到我想要的版本。 HTH 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:以防万一它对其他人有帮助,我在 .NET Standard 项目中遇到了这个问题,我错误地定义了目标框架:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.3;netstandard2.0;net45</TargetFramework>
</PropertyGroup>
...
When it should have been the plural TargetFrameworks (not TargetFramework):当它应该是复数TargetFrameworks (不是 TargetFramework)时:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0;net45</TargetFrameworks>
</PropertyGroup>
...
I had similar issue, i found out it was due to my nuget cache.我有类似的问题,我发现这是由于我的 nuget 缓存。
Command to clear cache : dotnet nuget locals all --clear
清除缓存的命令: dotnet nuget locals all --clear
After cache is cleared try restoring.清除缓存后尝试恢复。
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我通过在我的解决方案的每个项目中删除packages.config然后重新安装所有 Nuget 包来解决这个问题
Go to TOOLS under OPTIONS select NuGet Package Manager转到选项下的工具选择 NuGet 包管理器
Hit OK.点击确定。 Done you must be good to go.完成,你一定很高兴。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.