如何在任务 DotNetCoreCLI@2 中使用带有 --skip-duplicate 选项的“nuget push”

Mar*_*ijn 8 azure azure-devops

在 Azure DevOps 中,我想使用 dotnet 核心 CLI 任务来推送带有 --skip-duplicate 选项集的包。我怎么做?

我试图设置arguments: --skip-duplicate,但这并没有反映在执行的命令中。

我尝试使用 自定义命令custom: nuget push,但这表明 nuget push 不是有效的自定义命令。

如何使 DotNetCorCLI@2 任务执行dotnet nuget push <pathspec> --skip-duplicate(还将--source选项设置为内部包源)

Fre*_*gen 7

您应该能够使用 nugetauthenticate 和 nugetpush 而不是 dotnet core CLI。它还有更多功能

- task: NuGetAuthenticate@0
  displayName: 'NuGet Authenticate'
- task: NuGetCommand@2
  displayName: 'NuGet push'
  inputs:
    packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
    command: push
    feedsToUse: 'select'
    publishVstsFeed: 'feedname'
    allowPackageConflicts: true
Run Code Online (Sandbox Code Playgroud)


use*_*411 6

我遇到过同样的问题。我设法这样修复它:

- task: NuGetAuthenticate@0
- script: dotnet nuget push --api-key az --skip-duplicate --source https://pkgs.dev.azure.com/{organization}/{project?}/_packaging/{feed1}/nuget/v3/index.json *.nupkg
  workingDirectory: $(Build.ArtifactStagingDirectory)
Run Code Online (Sandbox Code Playgroud)

当然,请替换{organization}为您在 azure 中的组织名称。

{project?}如果您的 feed 是组织范围内的并且 {feed1}是您的 nuget feed 名称,则没有用。

默认情况下,NuGetAuthenticate 任务将验证 azure 中的所有源。要在 azure feeds 之外进行身份验证,请查看官方文档

更新

如果 nuget Push 随机失败并返回 401,可接受的解决方法是将这些变量添加到您的 yaml 中,如此处建议

variables:
  NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS: '30'
  NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS: '30'
Run Code Online (Sandbox Code Playgroud)


Cec*_*SFT 5

尝试使用custom: nuget并放入pushin 参数。检查以下语法:

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet nuget push'
  inputs:
    command: custom
    custom: nuget
    arguments: 'push *.nupkg -s https://pkgs.dev.azure.com/xxxx/_packaging/xxx/nuget/v3/index.json --skip-duplicate'
Run Code Online (Sandbox Code Playgroud)