Reputation: 23
Like the title says, I have a .NET class library solution/project that I would like to publish to an Azure Artifact Feed that exists. Here is the pipeline:
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: UseDotNet@2
- task: NuGetAuthenticate@1
- task: NuGetCommand@2
inputs:
command: restore
feedsToUse: config
- script: dotnet build --configuration Release
displayName: "Build Solution"
- script: dotnet pack --configuration Release --output '$(Build.ArtifactStagingDirectory)'
displayName: "Pack Project"
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: drop
Everything is running successfully, but the Artifact is not updated and some Microsoft SDK artifacts get added to the feed. What am I doing wrong?
Upvotes: 0
Views: 55
Reputation: 5642
The PublishBuildArtifacts@1 task is used to publish build artifacts to Azure Pipelines or a file share, not to the feed in Azure Artifact. You can find the published pipeline Artifact in the run.
To publish the Artifact to the feed in Azure Artifact, you can add a script task to run the dotnet nuget push
command after the dotnet pack
task. For more details, please refer Publish and restore NuGet packages from the command line (dotnet)
For example:
- script: dotnet nuget push --source https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json --api-key feed '$(Build.ArtifactStagingDirectory)/*.nupkg'
displayName: "publish NuGet packages"
You can also replace the source URL with the source name in your nuget.config file. Then the package will be published to the feed in Azure Artifact.
You can also refer more examples about Restore and push NuGet packages here.
Upvotes: 1