Search code examples
azure-devopsazure-pipelinesnugetazure-artifacts

Unable to publish NuGet packages to a feed in the same organization in Azure DevOps Artifact


I have a feed and a pipeline which I want to publish my artifacts based on this approach:

steps:
- task: NuGetToolInstaller@1                            # Minimum required NuGet version: 4.8.0.5385+.
  displayName: 'NuGet Tool Installer'

- task: NuGetAuthenticate@1
  displayName: 'NuGet Authenticate'

- script: |
      nuget.exe push -Source "https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" -ApiKey az $(Build.ArtifactStagingDirectory)\*.nupkg
  displayName: Push

The feed permissions are set as bellow:

Feed Permissions

The first two steps will be passed, but not the last one!

Result of second task:

Starting: NuGet Authenticate
==============================================================================
Task         : NuGet authenticate
Description  : Configure NuGet tools to authenticate with Azure Artifacts and other NuGet repositories. Requires NuGet >= 4.8.5385, dotnet >= 6, or MSBuild >= 15.8.166.59604
Version      : 1.247.4
Author       : Microsoft Corporation
Help         : https://aka.ms/NuGetAuthenticateTask
==============================================================================
Installing the Azure Artifacts Credential Provider (.NET Framework) to '/home/vsts/.nuget/plugins/netfx/CredentialProvider.Microsoft'. This credential provider is compatible with nuget.exe 4.8.0.5385 or later, and MSBuild 15.8.166.59604 or later.

Installing the Azure Artifacts Credential Provider (.NET Core) to '/home/vsts/.nuget/plugins/netcore/CredentialProvider.Microsoft'. This credential provider is compatible with .NET SDK 6 or later.

Setting up the credential provider to use the identity '($$Project$$) Build Service ($$ORG$$)' for feeds in your organization/collection starting with:
  https://pkgs.dev.azure.com/($$ORG$$)/
  https://($$ORG$$).pkgs.visualstudio.com/

Finishing: NuGet Authenticate

And finally the result of last step:

Starting: Push
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.246.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
nuget.exe push -Source "https://pkgs.dev.azure.com/($$ORG$$)/($$Project$$)/_packaging/($$FeedName$$)/nuget/v3/index.json" -ApiKey az /home/vsts/work/1/a\*.nupkg
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/304f2fc5-6e26-4112-ba5a-c1a70f9723cd.sh
/home/vsts/work/_temp/304f2fc5-6e26-4112-ba5a-c1a70f9723cd.sh: line 1: /opt/hostedtoolcache/NuGet/6.12.2/x64/nuget.exe: Permission denied

##[error]Bash exited with code '126'.
Finishing: Push

I tried this approach: Set Permission


Solution

  • Use the NuGetCommand@2 to push the packages:

    - task: NuGetCommand@2
      inputs:
        command: push
        packagesToPush: $(Build.ArtifactStagingDirectory)\*.nupkg
        nugetFeedType: internal
        publishVstsFeed: yourFeedName