简体   繁体   English

尝试恢复包时出错。 请再试一遍

[英]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?我怎样才能找出到底是什么导致了错误?

  1. Make sure you upgrade to the latest NuGet ( http://docs.nuget.org/docs/start-here/installing-nuget ).确保升级到最新的 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确保你正在做包恢复“正确的方式” http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

That should resolve the issue.那应该可以解决问题。

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:其次,我确保我有正确的路径源并单击可用的包源:

在此处输入图片说明

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我对此的解决方案是

  1. Close Visual Studio关闭 Visual Studio
  2. Remove the package folder with Explorer (or better only move it to another location)使用资源管理器删除包文件夹(或者最好只将其移动到另一个位置)
  3. Start Visual Studio启动 Visual Studio
  4. Go to the NuGet package manager and click Restore转到 NuGet 包管理器,然后单击“还原”

我通过下载最新版本的 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”。

The problem in my case我的问题

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.. 等。

在此处输入图片说明

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:使用记事本编辑器打开所有项目 .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 包来解决这个问题

In my case, I had another package source added which was like this.在我的例子中,我添加了另一个 package 源,就像这样。

在此处输入图像描述

I just removed this source from the NuGet package manager and rebuild the solution, it started working for me.我刚刚从 NuGet package 管理器中删除了这个源并重建了解决方案,它开始为我工作。

Go to TOOLS under OPTIONS select NuGet Package Manager转到选项下的工具选择 NuGet 包管理器

  1. General, Select Everything一般,全选
  2. Package Source, Select all required Source包源,选择所有需要的源

Hit OK.点击确定。 Done you must be good to go.完成,你一定很高兴。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试还原软件包时发生错误 - Error occurred trying to restore packages Facebook随机错误“发生了错误。 请稍后再试” - Facebook random error “An error occurred. Please try again later” 错误:构建恢复了 NuGet 包。 再次构建项目以在构建中包含这些包。 想要查询更多的信息 - Error: The build restored NuGet packages. Build the project again to include these packages in the build. For more information Facebook整合“发生错误,请稍后再试”? - Facebook integration “error occurred try again later”? “发生了错误。 请稍后再试”以尝试连接到Facebook(Windows Phone / C#SDK) - “An error occurred. Please try later” trying to connect to Facebook (Windows Phone/C# SDK) 我面临“您的登录尝试未成功”的问题,请重试。 实现自定义成员身份时出错 - I am facing “Your login attempt was not successful” Please try again. error while implementing custom membership 尝试并捕获错误“无法连接到数据库,请再试一次” - Try and catch Error “Unable to connect to DB please try again” 构建恢复了 NuGet 包。 再次构建项目以在构建中包含这些包 - The build restored NuGet packages. Build the project again to include these packages in the build 尝试检索授权组时,发生错误 (5) - While trying to retrieve the authorization groups, an error (5) occurred MonoDevelop错误:未知的MSBuild失败。 请再次尝试构建项目 - MonoDevelop Error: Unknown MSBuild failure. Please try building the project again
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM