问题描述
我使用 Teamcity(在 Internet 的虚拟机上运行)创建了一个 Nuget 服务器,并创建了将包发布到其中的构建.
I have created a Nuget Server using Teamcity (running on a virtual machine in internet) and created the build that publishes a package into it.
我还有另一个项目需要使用该包.这个项目也是建立在 teamcity 之上的.在我本地的 Visual Studio 上,我添加了 nuget feed uri,安装了包,一切正常.但是当我尝试在 teamcity 上构建它时,它说找不到包".
I also have another project that needs to use that package. This project is built on teamcity as well. On my local Visual Studio I added the nuget feed uri, installed the package and everything works fine. But when I try to build it on teamcity it says that "Package not found".
所以我的问题是:如何将自定义 nuget 提要添加到 TeamCity 构建中?"
So my question is : "How to add the custom nuget feed to TeamCity build?"
推荐答案
NuGet 包源是通过 Visual Studio 配置的,但它们存储在每个用户的配置文件中,位于 c:Users$USERAppDataRoamingNuGetNuGet.config
.TeamCity 包源的条目需要添加到运行构建的构建代理用户的配置文件中.
The NuGet package sources are configured through Visual Studio, but they're stored in a per-user configuration file, found at c:Users$USERAppDataRoamingNuGetNuGet.config
. The entry for the TeamCity package source needs to be added to the config file of the build agent user that's running your builds.
- 在您的本地计算机上,为您的用户打开 Nuget.config 文件
- 将 TeamCity 包源的条目复制到剪贴板
- 在构建代理上,为正在执行 TeamCity 构建的用户打开 NuGet.config 文件
- 粘贴到 TeamCity 包源条目中.保存&退出.
- 再次运行构建.它现在应该可以找到包了.
ladenedge 记录了我最初回答这个问题时不存在的一个很好的解决方案.如果您没有构建代理的管理员访问权限或想要基于每个项目配置包源,则该解决方案特别有用.
ladenedge documents a good solution that didn't exist when I originally answered this question. The solution is especially useful if you don't have admin access to the build agent or want to configure package sources on a per-project basis.
这篇关于如何将自定义 nuget 提要添加到 TeamCity 构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!