团队城市还原 TFS NuGet 源 401 未经授权



TeamCity Professional 2019.1.2 (build 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 FeatureNuGet feed credentials

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

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

但是在代理上运行的团队城市作业失败,并显示401 unauthorized

[15:30:52][restore] C:Program Filesdotnetsdk2.2.101NuGet.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 Filesdotnetsdk2.2.101NuGet.targets(114,5): error :   Response status code does not indicate success: 401 (Unauthorized).

我假设 shell dotnet 还原使用我的 Windows 登录信条 - 正是我的构建功能 NuGet 源凭据中指定的内容

请注意,我可以在 VisualStudio 中成功地使用相同的信条来管理 NuGet 包(在构建时还原包(。

尝试使用源 (TFS( 的键,而不是 url 本身。 喜欢这个;

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

如果这不起作用,请尝试手动添加用户凭据

nuget sources add -name foo.bar -source C:NuGetlocal -username foo -password bar -StorePasswordInClearText -configfile %AppData%NuGetmy.config

最新更新