【问题标题】:Publish NuGet Packages from TeamCity to Azure DevOps Artifacts将 NuGet 包从 TeamCity 发布到 Azure DevOps Artifacts
【发布时间】:2020-01-30 08:45:42
【问题描述】:

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

我应该将 PAT 传递给凭据提供程序,还是运行构建的帐户需要访问 Azure DevOps 才能生成凭据?文档对我来说有点不清楚这是如何工作的。我的 TeamCity 实例有点过时了,所以也许我需要先升级它。

【问题讨论】:

    标签: azure-devops nuget teamcity


    【解决方案1】:

    请为您的构建配置添加NuGet Credentials Provider build feature。指定提要的 URL(与在 NuGet 发布构建步骤中所做的相同)、有效的用户名 + PAT(不是密码)。

    【讨论】:

    • 为了让其他人受益于此线程:此解决方案无需安装 Microsoft 提供的“Azure Artifacts Credential Provider”。
    • 谢谢!在我们尝试了许多其他事情之后,这终于对我们有用。我希望这更明显。我们为此使用的 TeamCity 构建功能名为“NuGet 提要凭据”。这是版本 2021.1。
    【解决方案2】:

    接受的答案似乎不再有效。在 TeamCity 2019.1.4 上运行 Windows Server 2016 并使用 .NET Core 2.2.105:

    [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 Build 作业的上下文中不起作用。

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

    【讨论】:

    • 附录:我已经更新到 .NET Core SDK 3.1 和 NuGet 5.1 并且接受的答案现在正在工作。
    猜你喜欢
    • 2019-11-08
    • 2022-10-05
    • 2021-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-17
    • 2019-03-26
    • 2023-03-23
    相关资源
    最近更新 更多