Skip to content
Latchkey

How to Publish a NuGet Package in Azure Pipelines

The NuGetCommand task packs your project and pushes the resulting package to an Azure Artifacts feed.

Pack the project, then push to an internal feed by id. The task handles feed authentication for Azure Artifacts automatically.

Pack and push to a feed

Pack the csproj, then push the nupkg to the named internal feed.

azure-pipelines.yml
- task: NuGetCommand@2
  inputs:
    command: pack
    packagesToPack: src/MyLib/MyLib.csproj
- task: NuGetCommand@2
  inputs:
    command: push
    publishVstsFeed: my-org/my-feed
    packagesToPush: $(Build.ArtifactStagingDirectory)/**/*.nupkg

Notes

  • publishVstsFeed targets an internal Azure Artifacts feed without extra credentials.
  • Use allowPackageConflicts to tolerate re-pushing an existing version on retries.
  • For nuget.org, push to an external service connection instead of a VSTS feed.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →