本文介绍了如何获取 TFS2015 Build (Build.vnext) 和 NuGet 包还原以使用自定义包源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取我们的 TFS2015 Build (TFSBuild vnext) 与 VS Team Services 一起使用.

I'm trying to get our TFS2015 Build (TFSBuild vnext) going along with VS Team Services.

迄今为止大多数博客和文档 很有帮助,但在尝试构建使用自定义包源进行 NuGet 自动包还原的项目时除外.

Thus far most blogs and documentation has been helpful, except for when trying to build a project that uses custom package sources for NuGet automatic package restore.

我已经成功部署了一个团队服务构建代理(构建的新机制),一切似乎都很顺利,直到恢复 NuGet 包的构建任务失败.

I've successfully deployed an a Team Services Build Agent (the new mechanism for builds) and all seemed to go well until the build task to Restore NuGet packages failed.

失败是由于未从已安装的 VS 配置中提取自定义/私有包源,因此无法找到这些包.来自默认 NuGet 包源的传统包确实可以正常恢复.

The failure was due to custom/private package source not being picked up from the installed VS configuration, so those packages could not be found. The traditional packages from the default NuGet package feed did restore without issue.

如何指定 NuGet 在使用代理时使用的其他包源?

How do I specify the additional package sources for NuGet to use when using an agent?

vcastro 询问了 NuGet 安装程序构建步骤并在该构建步骤的配置中定义路径.以上是使用 Visual Studio Build 步骤和集成选项来拥有 NuGet 还原包.请参阅此图片以供参考:

vcastro asked about the NuGet Installer build step and defining paths in the configuration of that build step. The above is using the Visual Studio Build step and the integrated option to have NuGet restore packages. Refer this image for reference:

推荐答案

我在网上搜了一下,但收效甚微,但在摆弄以下内容后会有所帮助:

I've scrounged the web with little success, but after fiddling the following will help:

OK 似乎为 NuGet.config 配置的包源是按用户帐户存储的,例如

OK It seems that the package sources configured for NuGet.config is stored per user account, e.g.

c:Users<>AppDataRoamingNuGetNuGet.config

我的问题更难解决,因为构建代理在 Local System 帐户下作为 Windows 服务 运行.因此,为了获得用于构建的 NuGet 配置,我不得不改用以下路径:

My issue was harder to resolve, because the build agent was running as a Windows Service under the Local System account. So to get NuGet configuration to for the build, I had to use the following path instead:

  • 64 位 Windows C:WindowsSysWOW64configsystemprofileAppDataRoamingNuGetNuGet.Config
  • 32 位 Windows C:WindowsSystem32configsystemprofileAppDataRoamingNuGetNuGet.Config

您可能需要提升权限才能创建 NuGet 子文件夹和 NuGet.Config 文件.

You may need to have elevated permissions in order to create the NuGet subfolder and NuGet.Config file.

注意:我没有使用 Local Service 帐户的解决方案.以上仅适用于本地系统(或实际用户)帐户.

Note: I have no solution for using the Local Service account. The above only works for the Local System (or an actual user) account.

这篇关于如何获取 TFS2015 Build (Build.vnext) 和 NuGet 包还原以使用自定义包源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-03 20:54