从TeamCity发布NuGet包到Azure DevOps Artifacts

5

我正在尝试配置Azure Artifacts Credential Provider,以便让我连接到Azure DevOps并将NuGet软件包发布到Artifacts feed。我已在我的构建服务器上安装了凭据提供程序。但是每次运行构建时,我都会收到以下错误:

enter image description here

我应该向凭证提供程序传递PAT,还是正在运行构建的帐户需要访问Azure DevOps以生成凭据?对于这个问题,文档给我的解释不太清楚。我的TeamCity实例有点过时,也许我需要先升级它。
2个回答

9
请在构建配置中添加NuGet凭据提供程序构建特性。指定一个URL作为Feed(与NuGet发布构建步骤中所做的方式相同),以及有效的用户名+PAT(不要放密码)。

2
为了其他来到这个线程的人的利益:这个解决方案消除了安装微软提供的“Azure Artifacts凭据提供程序”的需要。 - sfuqua
1
谢谢!在我们尝试了许多其他方法之后,这终于对我们起作用了。我希望这更加明显。我们用于此的TeamCity构建功能名为“NuGet feed credentials”。这是版本2021.1中的内容。 - ProgrammierTier

3

被接受的答案似乎已经不再起作用。 在运行在Windows Server 2016上且使用.NET Core 2.2.105的TeamCity 2019.1.4中:

[push] WARNING: The credential plugin model used by 'C:\TeamCity\buildAgent\plugins\nuget-agent\bin\credential-provider\CredentialProvider.TeamCity.exe' is deprecated. Please contact the provider of the plugin for an alternative. More information about the recommended plugin model can be found at 'https://aka.ms/nuget-cross-platform-authentication-plugin'.
[17:18:31][push] Please provide credentials for: https://pkgs.dev.azure.com/org/project/_packaging/feed/nuget/v3/index.json
[17:18:31][push] Unable to load the service index for source https://pkgs.dev.azure.com/org/project/_packaging/feed/nuget/v3/index.json.
[17:18:31][push]   Response status code does not indicate success: 401 (Unauthorized).

如果我登录到服务器并设置非交互式使用的环境变量,则手动安装和运行 https://github.com/microsoft/artifacts-credprovider 可以从命令行工作,但在 TeamCity 构建作业上下文中不起作用。

是否有更新的 TeamCity 运行程序可以处理向 Azure Artifacts 推送 dotnet nuget 的身份验证?


2
附言:我已经升级到.NET Core SDK 3.1和NuGet 5.1,接受的答案现在可以正常工作。 - Chris Doherty

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