无法从私有Team City Nuget服务器运行Nuget包还原

7

当前讨论主题:http://devnet.jetbrains.com/message/5519081#5519081

错误报告:http://youtrack.jetbrains.com/issue/TW-37148

错误:无法在非交互模式下提示输入。

需要注意的一点是,凭据提示会在每次包下载时触发,而不是在开始时触发。我认为这可能是Team City调用NuGet的方式中存在的一个bug,但我不确定。

我已经配置了“NuGet Feed Credentials”构建功能,配置了基本身份验证,并在Firefox中运行了该Feed,在代理机器上显示出了要求凭据的包列表。

我的构建日志:https://gist.github.com/tonyeung/517597ca2312dad85f62

5个回答

3
以下是一个解决方法,可能会对你有所帮助,尽管我认为NuGet Feed凭据构建功能本来就应该能够解决这个问题。在这个例子中,我使用的是一个没有访客访问权限的内部TeamCity NuGet feed(称为Local)。 初始构建步骤(命令行-自定义脚本)
del /F %env.APPDATA%\NuGet\NuGet.Config
%teamcity.agent.tools.dir%\NuGet.CommandLine.DEFAULT.nupkg\tools\nuget.exe sources add -name Local -source %env.NuGetFeed%
%teamcity.agent.tools.dir%\NuGet.CommandLine.DEFAULT.nupkg\tools\nuget.exe sources update -Name Local -User %env.BuildServiceUser% -pass %env.BuildServicePassword%

就像我说的那样,这是一个解决方法,如果使用模板,维护起来也不会太麻烦。希望它能让您顺利运行。


谢谢,实际上我花了大约两天时间才得出几乎相同的解决方法。我没有采取构建步骤,而是将代理用户更改为新的受限用户,并将源和凭据添加到该用户的nuget.config中。 - ton.yeung

2
我知道这是一个老问题,但最近在TeamCity 9.1.7中我遇到了这个问题。
在我的情况下,问题是在“Administration > Global Settings”中找到的“Server URL”上有一个尾随斜杠。删除该斜杠使身份验证正常工作。

在从8迁移到TeamCity 10后,我遇到了相同的问题。在8中,如果没有斜杠,则构建失败,在10中,如果有斜杠,则构建失败。 - Benedict

1

为了解决问题,我已经采取以下措施:

http://localhost:80/httpAuth/app/nuget/v1/FeedService.svc: V2 feed在'http://localhost/httpAuth/app/nuget/v1/FeedService.svc/Packages(Id='***',Version='1.0.0')'返回了一个意外的状态码 '401 Unauthorized'。

  1. create local administrator account

    net user tcbagent password123 /add
    net localgroup administrators tcbagent /add
    
  2. attach "Logon as service" permissions (using Carbon PS helpers)

    Grant-CAPrivilege -Identity tcbagent "SeServiceLogonRight"
    
  3. create account within TeamCity
  4. run cmd using destination environment

    runas /user:tcbagent cmd
    
  5. add nuget source with credentials

    nuget sources add -name local -source http://localhost/httpAuth/app/nuget/v1/FeedService.svc -UserName tcbagent -Password password123 
    

    localhost of whatever you need

请检查您的teamcity-build.log文件,以获取类似以下内容的信息:
Starting NuGet.exe 3.5.0.1284 from C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT\tools\NuGet.exe
...
Restoring NuGet package xxxx.
...
Using credentials from config. UserName: tcbagent

TeamCity v9.1.7,NuGet v3.5.0-beta

我花了两天时间来解决这个问题,因为我对TeamCity和CI还很陌生。 希望这对你有所帮助。


1
针对 TeamCity 8.1.2(构建版本29993),我通过在 TeamCity 管理面板安装 Nuget v. 2.8.0 来解决此问题(我之前使用的是 v.2.8.2)。然后我添加了“Nuget Install”构建步骤,并设置了 NuGet Feed 凭证构建特性。 如果您更新 TeamCity,则可能也会解决此问题。

0

这需要更改nuget.config,我正在尝试在不更改它的情况下使其工作。 - ton.yeung

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接