Skip to content

Instantly share code, notes, and snippets.

@mwwhited
Last active December 15, 2020 00:10
Show Gist options
  • Save mwwhited/07936a71dcc06dc2697ed4a2a25ca668 to your computer and use it in GitHub Desktop.
Save mwwhited/07936a71dcc06dc2697ed4a2a25ca668 to your computer and use it in GitHub Desktop.

Create Private NuGet feed for use with Azure Devops

Summary

It is possible to host and publish to a private NuGet feed within Azure DevOps

Process

  • Under Artifacts click Create Feed
    • Name the feed as desired
    • select user visilibity (probably "Azure AD" or at least members of Project
    • upstream is optional.
    • set scope (probably for your project)
  • Within your project create a nuget.config file as below
    • set NameOfYourFeed as desired
    • set PathToYourFeed as shown under the connect to feed in the artifact from above
<configuration>
    <packageSources>
        <add key="NameOfYourFeed" value="PathToYourFeed" />
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    </packageSources>
</configuration>
  • Add steps to build pipeline
    • Authentication Pipeline to NuGet
    • Add dotnet nuget push
    • Ensure dotnet pack includes versioning

Pipeline NuGet Authentication

    - task: NuGetAuthenticate@0
      displayName: 'NuGet Authenticate'

Pipeline Nuget Push

    - task: DotNetCoreCLI@2
      displayName: Push Packages to Private NuGet
      inputs:
        command: 'push'
        packagesToPush: '$(build.artifactStagingDirectory)/**/*.nupkg'
        nuGetFeedType: 'internal'
        publishVstsFeed: 'FEED-ID'

Pipeline Dotnet Pack Versioning

    - task: DotNetCoreCLI@2
      displayName: Package to Staging directory
      inputs:
        command: custom
        custom: 'pack'
        arguments: 'yoursolution.slnproj -c=$(BUILD_CONFIGURATION) -o $(Build.ArtifactStagingDirectory) /p:Version=$(fullSemVer)'
        verbosityRestore: Minimal
        verbosityPack: Minimal
        feedsToUse: select
        vstsFeed: personalnugetfeed
        nuGetFeedType: internal
        includeNuGetOrg: true

Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment