【问题标题】:Use NuGetCommand@2 to push packages to nuget.org使用 NuGetCommand@2 将包推送到 nuget.org
【发布时间】:2021-03-17 23:14:16
【问题描述】:

documentation here

要发布到外部 NuGet 源,您必须首先创建一个服务连接以指向该源....

然后它提供这个 YAML:

- task: NuGetAuthenticate@0
  inputs:
    nuGetServiceConnections: '<Name of the NuGet service connection>'
- task: NuGetCommand@2
  inputs:
    command: push
    nuGetFeedType: external
    versioningScheme: byEnvVar
    versionEnvVar: <VersionVariableName>

这失败了

“错误:'https://api.nuget.org/v3/index.json' 的服务连接无效。此任务不支持 ApiKey 服务连接。请改用 -ApiKey (NuGet) 或调用工具本身时 --api-key (dotnet)。有关详细信息,请参阅任务文档。"

我使用我的 ApiKey 创建了一个指向 nuget.org 的服务连接。

我不理解这部分错误消息:“在调用工具本身时,请使用 -ApiKey (NuGet) 或 --api-key (dotnet)。有关更多详细信息,请参阅任务文档。”

我还看到了this question,它指的是一个已经实施的缺陷。

编辑:原来上面提到的缺陷是一个红鲱鱼。真正的问题是 nuget 的限制,在撰写本文时仍然存在。

【问题讨论】:

    标签: nuget azure-pipelines azure-pipelines-yaml


    【解决方案1】:

    根据NuGet Authenticate task document

    一些包源,例如 nuget.org 使用 API 密钥进行身份验证 推送包时,而不是用户名/密码凭据。到期的 由于 NuGet 的限制,此任务不能用于设置 NuGet 使用 API 密钥的服务连接

    改为:

    1. 配置一个包含 ApiKey 的秘密变量

    2. 执行打包 使用 nuget push -ApiKey $(myNuGetApiKey) 或 dotnet nuget push 推送 --api-key $(myNuGetApiKey),假设您将变量命名为 myNuGetApiKey

    【讨论】:

    • AFAIK 没有一个 Microsoft 文档提供了如何将 nuget 包发布到地球上最大的 nuget 包存储库 nuget.org 的工作示例。我知道的唯一端到端示例由KUTline 提供,可以在here 找到。
    猜你喜欢
    • 1970-01-01
    • 2021-04-15
    • 2018-02-17
    • 2016-08-08
    • 2018-06-12
    • 2020-07-13
    • 2019-07-04
    • 2015-09-13
    • 2023-03-27
    相关资源
    最近更新 更多