azure-devopsnugetazure-pipelinesartifacts

How can I use Artifacts from "This feed" source in my pipeline?


I have successfully pushed my NuGet package to a feed in my Azure DevOps Artifacts:

enter image description here

But, I want to use this package in my pipeline, because this currently fails because it cannot find the package. I tried to add a service connection in my Project Settings, using the URL I get when creating the artifact feed:

enter image description here

But still, my build fails because it cannot find the package.

This is my pipeline YAML file:

trigger:
  batch: true
  branches:
    include:
    - master
    - develop
    - release/*

pr:
  autoCancel: false
  branches:
    include:
    - master
    - develop
    
pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetAuthenticate@0
  inputs:
    nuGetServiceConnections: 'Azure DevOPS Nuget feed (see Artifacts)'
- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'
    feedsToUse: config
    nugetConfigPath: nuget.config
    externalFeedCredentials: 'Azure DevOPS Nuget feed (see Artifacts)'

- task: GitVersion@5
  inputs:
    runtime: 'full'
    updateAssemblyInfo: true

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

Update: it seems to go to the correct NuGet feed now, but it fails to authenticate in step NuGetCommand.

How can I use the NuGet package I just pushed to the Artifact feed in Azure DevOps?


Solution

  • I used the DevOps YAML editor to add the correct steps to my azure-pipelines.yml. I added a NuGet step:

    enter image description here

    In the Use packages from this Azure Artifacts/TFS feed option, I could select my Artifacts feed. This added this task to the YAML file:

    - task: NuGetCommand@2
      inputs:
        command: 'restore'
        restoreSolution: '**/*.sln'
        feedsToUse: 'select'
        vstsFeed: '<<UUID>>'
    

    And it worked!