【问题标题】:TeamCity restore TFS NuGet feed 401 unauthorizedTeamCity 还原 TFS NuGet 提要 401 未经授权
【发布时间】:2019-12-27 05:24:30
【问题描述】:

TeamCity Professional 2019.1.2(内部版本 66342)

NuGet.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="globalPackagesFolder" value=".\packages" />
  </config>
  <packageSources>
    <add key="TFS" value="https://tfs.mydomain.com/nuget/nuget" />
  </packageSources>
</configuration>

我有一个 .NET CLI (dotnet) restore 构建步骤,包括 Build Feature NuGet feed credentials

从本地 shell 运行时,相应的命令可以正常工作:

>  "C:\Program Files\dotnet\dotnet.exe" restore MySolution.sln
> --packages \\packages --source https://tfs.mydomain.com/nuget/nuget --runtime win-x64 --configfile NuGet.config

但在代理上运行的 TeamCity 作业失败并显示 401 unauthorized

[15:30:52][restore] C:\Program Files\dotnet\sdk\2.2.101\NuGet.targets(114,5): error : Failed to retrieve information about 'Dapper' from remote source 'https://tfs.mydomain.com/nuget/nuget/FindPackagesById()?id='Dapper'&semVerLevel=2.0.0'.


[15:30:52][restore] C:\Program Files\dotnet\sdk\2.2.101\NuGet.targets(114,5): error :   Response status code does not indicate success: 401 (Unauthorized).

我假设 shell dotnet restore 使用我的 Windows 登录凭据 - 正是我的构建功能 NuGet 提要凭据中指定的内容

请注意,我可以在 VisualStudio 中成功使用相同的凭据来管理 NuGet 包(在构建时恢复包)。

【问题讨论】:

  • 您可以直接在 teamcity 服务器上的浏览器中打开提要 url https://tfs.mydomain.com/nuget/nuget 吗?据我所知,TFS 服务器上的提要应该以 .json 或您提供的唯一替代字符结尾?你的 nuget.exe 版本是什么?
  • 是的,在安装了 TeamCity Server 和 Build Agent 的机器上,我可以在 Internet Explorer(但不是 Firefox)中打开 feed https://tfs.mydomain.com/nuget/nuget。 IE 似乎已经缓存了我的凭据 - 当我第一次尝试这个时,我可能会被提示输入用户名/密码,但我不记得了。请注意,TFS 凭据与我在 TC 服务器的域登录凭据不同。我在 NuGet.exe v4.7.0.5148

标签: tfs nuget teamcity restore http-status-code-401


【解决方案1】:

尝试使用源 (TFS) 的密钥,而不是 url 本身。 像这样;

"C:\Program Files\dotnet\dotnet.exe" restore MySolution.sln --packages \\packages --source tfs --runtime win-x64 --configfile NuGet.config

如果这不起作用,请尝试添加您的用户凭据 manually

nuget sources add -name foo.bar -source C:\NuGet\local -username foo -password bar -StorePasswordInClearText -configfile %AppData%\NuGet\my.config

【讨论】:

  • 源的键是什么意思? tfs有什么特殊含义?
  • 我尝试了您的建议,但 tfs 被解释为当前目录之外的子文件夹的名称。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-06
  • 2018-05-19
  • 2020-06-11
  • 2017-02-22
  • 2018-10-08
  • 2018-01-05
相关资源
最近更新 更多