Search code examples
azure-devopsnugetpipeline

Azure Devops restoring from multiple private nuget sources (same type)


In Azure pipelines, the Nuget Restore task allows me to specify a feed in my organization. However, that feed can apparently only have one upstream source per type (nuget, npm, etc.), and that upstream source is nuget.org. I have another nuget feed that I need to pull in as well, but since we're only allowed to have one upstream nuget source for our custom feeds, I'm not quite sure how best to tackle this.

edit: Actually, even after removing nuget.org as the upstream branch, I still can't add another upstream branch aside from NPM.. I thought it was unable to be selected because I already had Nuget.org included.

enter image description here


Solution

  • Refer to this doc: Enable upstream sources in an existing feed

    Custom public upstream sources are only supported with npm registries.

    The cause of the issue is that custom public upstream sources are only supported with NPM registries. This is the limitation of Azure Artifacts.

    For a workaround, to use multiple private nuget sources, you can define the nuget resource in Nuget.config file and create nuget Service connection in Project Settings -> Service connections.

    Then you can use the service connections in nuget restore task.

    For example:

    enter image description here

    Update:

    Nuget Restore task sample:

    - task: NuGetCommand@2
      displayName: 'NuGet restore'
      inputs:
        feedsToUse: config
        nugetConfigPath: $(build.sourcesdirectory)/targetfolder/nuget.config
        externalFeedCredentials: 'nuget1027, test nuget feed'