NuGet软件包还原未还原构建中的软件包 [英] NuGet Package Restore is not restoring packages on build

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

问题描述

我将我们的源代码从Vault移到TFS,而不用担心迁移或其他任何事情,只是获取最新的Vault并将其添加到TFS.

I am moving our source code from Vault to TFS, not bothering with the migration or anything, just pulling a get latest in vault and adding it to TFS.

该解决方案有多个项目,每个项目都有至少一个NuGet软件包.我正在尝试使Package Restore再次工作.它可以在Vault中工作(但不能达到预期的效果).我的期限很短,一开始它没有用,所以我添加了一个Pre-Build事件,以针对每个项目的packages.config运行nuget.exe.

The solution has got several projects, and each one has at least one NuGet package. I am trying to get Package Restore working again. It worked in Vault (but not the way it was supposed to). I was under a bit of a deadline, and it did not work at first, so I added a Pre-Build event to run nuget.exe against the packages.config for each project.

TFS构建服务对此表示抱怨,因此我试图使其正确"运行.

TFS build service complains about that, so I am trying to get it working "right".

  1. 我已经在Visual Studio工具菜单中设置了该选项.
  2. 我已经安装了NuGetEnablePackageRestore并运行此修复程序.
  3. 我已确认packages目录是源代码控制,但为空.
  4. 我已经验证了每个项目文件都包含以下内容:

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

以诊断级别的详细程度进行构建表明,每个项目都会评估这些属性,但是从不执行nuget.targets中的RestoreCommand.

Building with Diagnostic level verbosity reveals that each project evaluates those properties, but the RestoreCommand in nuget.targets is never executed.

有什么想法吗?

我尝试通过以下链接实施解决方案:

I have attempted to implement the solutions from these links:

  1. nuget-程序包还原不起作用
  2. NuGet软件包还原不起作用-我确实在此处发布了问题/评论要求澄清...
  3. http://nuget.codeplex.com/workitem/1879
  1. nuget - package restore not working
  2. NuGet Package Restore Not Working - I did post a question/comment on there asking for clarification...
  3. http://nuget.codeplex.com/workitem/1879

编辑

此外,我发现在构建期间正在评估RestoreCommand属性.诊断详细信息显示:

Edit

Additionally, I have found that the RestoreCommand property is being evaluated during build. Diagnostic Verbosity shows:

RestoreCommand = (set EnableNuGetPackageRestore=true) && "C:\Source\Kiersted Direct And Related\Direct\Kiersted\.nuget\nuget.exe" install "packages.config" -source "@(PackageSource)" -o "C:\Source\Kiersted Direct And Related\Direct\Kiersted\packages"

推荐答案

我知道了,然后在这里找到了答案:

I figured it out, and I found the answer here: MSBuild not running BuildDependsOn tasks from an imported project

问题(在查看诊断详细信息生成输出之后)是BuildDependsOn设置未设置.我的项目文件每个都有导入语句

The problem (after looking through the Diagnostic verbosity build output) was that the BuildDependsOn setting was getting un-set. My project files each had the import statement

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

但是该语句位于XML树的开头.显然,Microsoft.CSharp.targets的导入可能会干扰该导入,从而影响BuildDependsOn.

but that statement was at the beginning of the XML tree. Apparently the import for Microsoft.CSharp.targets can interfere with that import and thus the BuildDependsOn.

我的解决方案是将nuget.targets导入移动到Microsoft.CSharp.targets导入下方.现在,所有东西的构建都非常漂亮.

My solution was to move the nuget.targets import to below the Microsoft.CSharp.targets import. Now everything builds beautifully.

这篇关于NuGet软件包还原未还原构建中的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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