NuGet 包还原不起作用 [英] NuGet Package Restore Not Working

查看:63
本文介绍了NuGet 包还原不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一台计算机上签入一个项目,在另一台计算机上签出,发现 NuGet 安装的二进制文件丢失了.我也可以将它们签入源代码管理,但看起来有更好的解决方案:

I checked in a project on one computer, checked out on another, and find that the binaries installed by NuGet are missing. I could check them in to source control as well, but it looks like there's a better solution:

http://docs.nuget.org/docs/workflows/using-nuget-无提交包

我按照这些说明进行操作,现在应该有一个 .nuget 文件夹,在我的 .csproj 文件中有以下条目:

I followed those instructions, now have a .nuget folder where one should be, have the following entries in my .csproj file:

<RestorePackages>true</RestorePackages>
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />

然而,当我重建我的解决方案时,丢失的包没有恢复.

and yet when I rebuild my solution, the missing packages are not restored.

我错过了什么?如何诊断此问题?

What am I missing? How can I diagnose this problem?

推荐答案

请注意,您可以通过在 nuget 包管理器控制台中运行以下命令来强制执行包还原

Note you can force package restore to execute by running the following commands in the nuget package manager console

更新包-重新安装

强制重新安装解决方案中的所有内容.

Forces re-installation of everything in the solution.

Update-Package -Reinstall -ProjectName myProj

Update-Package -Reinstall -ProjectName myProj

强制重新安装 myProj 项目中的所有内容.

Forces re-installation of everything in the myProj project.

注意:这是核选项.使用此命令时,您可能无法获得与已安装的软件包版本相同的版本,这可能会导致问题.与解决方案级别相比,这不太可能发生在项目级别.

Note: This is the nuclear option. When using this command you may not get the same versions of the packages you have installed and that could be lead to issues. This is less likely to occur at a project level as opposed to the solution level.

您可以使用 -safe 命令行参数选项来限制升级到具有相同主要和次要版本组件的较新版本.这个选项是后来添加的,解决了评论中提到的一些问题.

You can use the -safe commandline parameter option to constrain upgrades to newer versions with the same Major and Minor version component. This option was added later and resolves some of the issues mentioned in the comments.

更新包-重新安装-安全

Update-Package -Reinstall -Safe

这篇关于NuGet 包还原不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆