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)/**/*.nupkgNotes
- 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
How to Use Variable Templates in Azure PipelinesShare variables across Azure Pipelines with a variable template file, including it under variables so many pi…
How to Run a Matrix Across OS in Azure PipelinesRun a job across Linux, Windows, and macOS in Azure Pipelines with a strategy matrix that swaps the vmImage p…