简体   繁体   English

如何为vs2015项目恢复NuGet包

[英]How to restore NuGet packages for vs2015 project

I just built a new PC, installed my dev tools, connected to TFS and downloaded my project. 我刚刚构建了一台新PC,安装了我的开发工具,连接到TFS并下载了我的项目。 Now most of my references are broken to EF, jQuery, etc. 现在我的大多数参考文献都被分解为EF,jQuery等。

The packages folder is missing all the .dlls, if I try to use NuGet restore nothing happens. packages文件夹缺少所有的.dll,如果我尝试使用NuGet恢复没有任何反应。 If I use NuGet manager for Solution there is no "force" reinstall option. 如果我使用NuGet管理器解决方案,则没有“强制”重新安装选项。

NuGet seems to be more a hindrance than a help. NuGet似乎更像是一种障碍,而不是一种帮助。

You can run " Update-Package -reinstall " command from Package Manager Console in VS to force reinstall all the packages. 您可以从VS中的程序包管理器控制台运行“ Update-Package -reinstall ”命令以强制重新安装所有程序包。

Package authors often need to reinstall the same version of package they are developing to test the behavior. 软件包作者通常需要重新安装他们正在开发的相同版本的软件包来测试行为。 The command Install-Package does not provide '-force' option, that could forcefully reinstall a package. 命令Install-Package不提供'-force'选项,可以强制重新安装包。 So, Update-Package -reinstall is added to meet that requirement. 因此,添加了Update-Package -reinstall以满足该要求。

I've had that same issue plenty of times when I need to re-download code after getting a new PC. 当我需要在购买新PC后重新下载代码时,我已经有过相同的问题了。 Here's what worked for me: 这对我有用:

  1. Download the project from TFS (or in your case SVN). 从TFS(或您的SVN)下载项目。
  2. Delete the "packages" folder 删除“packages”文件夹
  3. Make sure the "Package Manager Console" is enabled (Tools -> NuGet Package Manager -> Package Manager Console) 确保已启用“程序包管理器控制台”(工具 - > NuGet程序包管理器 - >程序包管理器控制台)
  4. Open the solution file. 打开解决方案文件。
  5. At the right side of the "Package Manager Console," a "Restore" button should appear. 在“程序包管理器控制台”的右侧,应出现“恢复”按钮。 Click on the "Restore" button. 单击“恢复”按钮。

Hope that helps you. 希望对你有所帮助。

I'm not sure if I'm supposed to share the link if I already answered a similar question or just answer again, so I'm doing both. 如果我已经回答了类似问题或者只是回答了问题,我不确定我是否应该分享这个链接,所以我这两个都做了。 Here's the link to the same answer from a different asker. 这是来自不同提问者的相同答案链接

Edit: If after you complete the above steps you are still getting syntax errors from missing references, right-click on References in the Solution Explorer and then just hit OK. 编辑:如果在完成上述步骤后仍然会从缺少的引用中获得语法错误,请在解决方案资源管理器中右键单击“引用”,然后单击“确定”。 That fixed the problem with the references for me. 这解决了我的参考问题。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM