TeamCity Nuget安装构建步骤不使用多个源,其中一个是TC的私有NuGet源

时间:2012-12-31 14:23:12

标签: teamcity nuget teamcity-7.1

在将源设置为TeamCity的NuGet服务器时,我在NuGet Install构建步骤中收到以下错误:

Step 1/4: NuGet install (NuGet Installer) (3s)

[15:11:19][Step 1/4] scan: Searching for nuget.config files

[15:11:19][Step 1/4] install: Installing NuGet packages for packages.config (3s)

[15:11:19][install] NuGet command: C:\TeamCity\buildAgent\tools\NuGet.CommandLine.2.2.0.nupkg\tools\NuGet.exe install C:\TeamCity\buildAgent\work\a4b9de5be22a981\packages.config -OutputDirectory C:\TeamCity\buildAgent\work\a4b9de5be22a981\packages -Source http://localhost:9090/guestAuth/app/nuget/v1/FeedService.svc

[15:11:19][install] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script96367186180319830.cmd

[15:11:19][install] in directory: C:\TeamCity\buildAgent\work\a4b9de5be22a981

[15:11:22][install] The remote server returned an error: (404) Not Found.

[15:11:22][install] Process exited with code 1

[15:11:22][Step 1/4] Step NuGet install (NuGet Installer) failed

如果我将sources字段留空,它将从默认提要(NuGet社区提要)中找到NuGet包,但不会在TC的NuGet提要中本地构建和打包并托管它们。

如何在NuGet安装程序构建步骤中同时使用默认提要和内部TC的NuGet提要?

3 个答案:

答案 0 :(得分:16)

您可以通过nuget.config文件为解决方案指定自定义Feed。

关键是提供凭据部分packageSourceCredentials,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="Local" value="http://localhost:9090/httpAuth/app/nuget/v1/FeedService.svc" />
  </packageSources>
  <activePackageSource>
    <add key="Local" value="http://localhost:9090/httpAuth/app/nuget/v1/FeedService.svc" />
  </activePackageSource>
  <packageSourceCredentials>
    <Local>
      <Username>login</Username>
      <Password>pa$$w0rd</Password>
    </Local>
  </packageSourceCredentials>
</configuration>

config文件应位于存储库中的sln文件旁边。

答案 1 :(得分:3)

这似乎是TeamCity的known issue。解决方法建议通过命令行客户端添加包源,然后使用授权凭据更新这些源:

nuget sources add -name [name] -source [feedUrl]
nuget sources update -Name [name] -User [username] -pass [password]

我的理解是Nuget会为将来的请求缓存这些凭据。我不知道缓存的清除频率;您可能需要在启动构建之前运行nget sources update以确保缓存一致。

答案 2 :(得分:3)

我们在TeamCity插件中实现了经过身份验证的Feed支持。请关注问题http://youtrack.jetbrains.com/issue/TW-20764

的评论
相关问题