tfs - TeamCity 还原 TFS NuGet 提要 401 未经授权
问题描述
TeamCity 专业版 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 包(在构建时恢复包)。
解决方案
尝试使用源 (TFS) 的密钥,而不是 url 本身。像这样;
"C:\Program Files\dotnet\dotnet.exe" restore MySolution.sln --packages \\packages --source tfs --runtime win-x64 --configfile NuGet.config
如果这不起作用,请尝试手动添加您的用户凭据
nuget sources add -name foo.bar -source C:\NuGet\local -username foo -password bar -StorePasswordInClearText -configfile %AppData%\NuGet\my.config
推荐阅读
- javascript - 样式“text-stroke”是否有任何 document.execCommand()?
- python - 根据条件在df中附加单元格值
- python - 我试图更新我的个人资料下的所有现有值,但它不起作用 - Python selenium
- configuration - Docker下的Kong Gateway Manager:如何为控制台配置CORS
- angular - 在 Angular 服务中没有返回任何值
- python - 在同一行运行多个 IPython 魔术命令
- docker - 带有嵌套 docker 命令的 sudo/visudo
- flutter - Flutter应用程序全屏代码不起作用
- r - 如何在用 highcharter 制作的箱线图中添加平均值?
- excel - 尝试保护工作簿和保护共享时出错