aksvinu
aksvinu

Reputation: 191

Azure DevOps: Can not load nuget package from feed in Azure Pipeline if feed name is used

I have a Azure feed named sampleFeed in a project sampleProject which is in organization sampleOrganization. When I am restoring packages in my build pipeline I am getting error ##[error]The nuget command failed with exit code(1) and error(Unable to load the service index for source https://pkgs.dev.azure.com/sampleOrganization/_packaging/sampleFeed/nuget/v3/index.json.

yaml pipeline steps to restore package is as below:

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

 - task: NuGetCommand@2
  displayName: 'NuGet Restore'
  inputs:
    restoreSolution: '**/SampleService.csproj'
    vstsFeed: $(parameter-feedName)

On debugging I have found that path created automatically by the task NuGetCommand@2 is invalid. Valid URI of the feed is https://pkgs.dev.azure.com/sampleOrganization/sampleProject/_packaging/sampleFeed/nuget/v3/index.json where as URI created by task has no project information in path.

When I pass feed GUID (eg: 81ffa918-1abb-4e49-8a2c-dfec591be544/b7576616-ad83-4e2c-a553-d8f1ceeb5dfc) instead of feedName, correct URI is formed and pipeline works without any issue.

My question is am I doing something wrong or is this issue with the task NuGetCommand@2? I don't want to work with the GUID as to figure out feed GUID additional manual steps are required.

Upvotes: 1

Views: 846

Answers (1)

Stepness
Stepness

Reputation: 97

If you are using a project scope feed you may need to add the project in front of the feed name, like sampleProject/sampleFeed inside parameter-feedName.

It should be like the first example here.

# Restore from a project scoped feed in the same organization
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    feedsToUse: 'select'
    vstsFeed: 'my-project/my-project-scoped-feed'
    includeNuGetOrg: false
    restoreSolution: '**/*.sln'

Upvotes: 1

Related Questions