简体   繁体   English

TFS NuGet还原包不起作用 - Microsoft.webapplication.targets

[英]TFS NuGet Restore Package Not Working - Microsoft.webapplication.targets

I have recently started to implement an automated build for our software suite using TFS. 我最近开始使用TFS为我们的软件套件实现自动构建。 I am trying to install as little as possible on the build server and would like to avoid checking in third party libraries to our source repository. 我试图在构建服务器上尽可能少地安装,并希望避免在我们的源存储库中检入第三方库。

One of our projects fails the build with with a missing dependency: 我们的一个项目使构建失败,缺少依赖:

<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />

This is not surprising, as I don't have Visual Studio (or Team Explorer etc.) installed on the build server. 这并不奇怪,因为我没有在构建服务器上安装Visual Studio(或团队资源管理器等)。 In an effort to work around this issue, I am trying to use NuGet with automatic package restore to provide the appropriate library (MSBuild.Microsoft.VisualStudio.Web.targets). 为了解决这个问题,我试图使用NuGet自动包恢复来提供适当的库(MSBuild.Microsoft.VisualStudio.Web.targets)。 I have read a ton of posts both here and elsewhere, but have not been able to get this to work properly. 我已经在这里和其他地方阅读了大量的帖子,但未能使其正常工作。 Basically, I: 基本上,我:

  1. Set an environment variable on the build server: EnableNuGetPackageRestore=true 在构建服务器上设置环境变量:EnableNuGetPackageRestore = true
  2. Followed the instructions at: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages 按照以下说明操作: http//docs.nuget.org/docs/workflows/using-nuget-without-committing-packages
  3. Added all files in SolutionDir.nuget to the TFS repository. 将SolutionDir.nuget中的所有文件添加到TFS存储库。
  4. Add the packages folder and respositories.config to the TFS repository. 将packages文件夹和respositories.config添加到TFS存储库。
  5. Verified that nuget.targets was referenced from the offending project. 已验证nuget.targets是从违规项目中引用的。
  6. Verified that 'RestorePackages' was set to true in the offending project. 验证在违规项目中'RestorePackages'设置为true。
  7. Shelved all these items and queued a private build with the proper shelveset. 搁置所有这些物品,并用适当的货架排队私人建造。

The build runs, but the nuget packages are never downloaded. 构建运行,但永远不会下载nuget包。 Further to that, I don't see any log entries for any 'RestoreCommand' (or other items from the nuget.targets) in the build log file. 除此之外,我没有在构建日志文件中看到任何“RestoreCommand”(或nuget.targets中的其他项)的任何日志条目。 It is like the nuget.targets is completely ignored. 它就像nuget.targets完全被忽略了。 I'm hoping I've just been looking at this too long and have missed some simple step. 我希望我一直在看这个太长时间并错过了一些简单的步骤。

Edit: I should have mentioned that the solution builds fine on a local machine. 编辑:我应该提到解决方案在本地计算机上构建良好。 I have updated the project references to reference the libraries from NuGet. 我已更新项目引用以引用NuGet中的库。 If I delete all the local packages it downloads them and builds properly. 如果我删除所有本地软件包,它会下载并正确构建。

I know this is an old question but here is how I got this working. 我知道这是一个老问题,但这是我如何工作的。

I followed the instructions here so I do not have to add the packages folder to TFS: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages 我按照这里的说明进行操作,因此我不必将包文件夹添加到TFS: http//docs.nuget.org/docs/workflows/using-nuget-without-committing-packages

I then had to use the simple build file that is mentioned in this link http://docs.nuget.org/docs/reference/package-restore-with-team-build which simply triggers the package restore beforehand. 然后我不得不使用此链接http://docs.nuget.org/docs/reference/package-restore-with-team-build中提到的简单构建文件,它只是事先触发包恢复。

All I had to change from the build file was the path to my solution file and the nuget.exe as mine differed. 我必须从构建文件更改的是我的解决方案文件的路径和我的nuget.exe不同。

I then configured TFS to use the build.proj file rather than the solution. 然后我将TFS配置为使用build.proj文件而不是解决方案。

Please note I also upgraded to nuget 2.7 so I didn't have to include the .targets file. 请注意我也升级到了nuget 2.7,所以我不必包含.targets文件。

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

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