Thursday, May 27, 2021

Publish packages to nuget.org

You can follow different path in order to publish your package into nuget.org. The prerequisites and the steps are described in Microsoft documentation page

If you get an Error 403 (The specified API Key is invalid, has expired, or does not have permission to access the specified package.) it simply indicates that the package name you chose has already been published and you are not allowed to overwrite it. Which makes sense when you upload yours and do not want other people make changes to it without you providing them an API Key.

One good practice is to create packages using a different API key than upgrading to a new version. This will make sure that your deployment pipeline will fail if the name does not exist and it would create a new package every time you deploy it.

When publishing a nuget package to Azure DevOps Artifacts you do similarly using nuget push command:

    - taskDotNetCoreCLI@2
      displayName'dotnet push'
      inputs:
        commandpush
        packagesToPush'$(Build.ArtifactStagingDirectory)/*.nupkg'
        nuGetFeedType'internal'
        publishVstsFeed'feed-name-or-id'
      conditionand(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))