Publish a Package to Azure Artifacts
This tutorial walks you through publishing a NuGet package to an Azure Artifacts feed using Azure Pipelines.
Prerequisites
- Azure DevOps organization with a project
- Feed created in Artifacts
- Basic knowledge of YAML pipelines
1️⃣ Create a Feed
Navigate to Artifacts → Create Feed. Give it a name, e.g., my-feed
.
2️⃣ Add a .csproj
and .nuspec
Make sure your project includes the necessary metadata for a NuGet package.
<PropertyGroup>
<PackageId>MyLibrary</PackageId>
<Version>1.0.0</Version>
<Authors>YourName</Authors>
<Description>A sample library</Description>
</PropertyGroup>
3️⃣ Configure the Pipeline
Create azure-pipelines.yml
in the repo root:
trigger:
- main
variables:
buildConfiguration: 'Release'
feedName: 'my-feed'
stages:
- stage: Build
jobs:
- job: Build
pool:
vmImage: 'windows-latest'
steps:
- task: NuGetToolInstaller@1
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
inputs:
command: 'pack'
packagesToPack: '**/*.csproj'
versioningScheme: 'off'
arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
- stage: Publish
dependsOn: Build
condition: succeeded()
jobs:
- job: Publish
pool:
vmImage: 'windows-latest'
steps:
- task: NuGetCommand@2
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
publishVstsFeed: '$(feedName)'
versioningScheme: 'off'
4️⃣ Run the Pipeline
Commit and push the YAML file. Azure Pipelines will automatically trigger a build.
5️⃣ Verify the Package
Go to Artifacts → my‑feed. You should see MyLibrary 1.0.0
listed.
💡 Tips & Best Practices
- Use
semantic versioning
for easier dependency management. - Enable Upstream sources if you need packages from NuGet.org.
- Set Retention policies to keep the feed clean.