1

I have an azure devops package feed which was working fine for my purposes, until recently a hard drive failure disrupted operations. Suddenly I found myself unable to push any packages without running into a 401 response. I was able to get it to work eventually after modifying a nuget.config file as described in the answer to this question, but given that this entire process was fairly convoluted, it seems like there should be a much more straight-forward way to set this up when needed. So that in the case I ever need to do this again in the future, and so that I don't have to rely on getting lucky with stack overflow answers, what is the best, most straight-forward method for setting up publishing to azure devops package feeds?

RTD
  • 334
  • 2
  • 12
  • nuget.config is the most commonly used authentication method for push packages to feed. Do you mean you want a push method that can ***'Create once, use for a long time.'***? If so, see my answer. :) – Bowman Zhu-MSFT Oct 10 '22 at 07:10

1 Answers1

2

nuget.config is the most commonly used authentication method for push packages to feed. There are two ways to push packages to feed, I think you may need another.

Pipeline push should be a easy way to achieve your requirement.

trigger:
- none

pool:
  vmImage: 'windows-latest'

steps:
- checkout: self
  persistCredentials: true #This step will do the auth.
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    arguments: '--configuration Debug'

- task: DotNetCoreCLI@2
  inputs:
    command: 'pack'
    packagesToPack: '**/*.csproj'
    versioningScheme: 'byPrereleaseNumber'
    majorVersion: '1'
    minorVersion: '0'
    patchVersion: '2'

- task: NuGetCommand@2
  inputs:
    command: 'push'
    packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
    nuGetFeedType: 'internal'
    publishVstsFeed: 'xxx/xxx'

enter image description here

You just need to 'click' the feed you want push to and then change the step of YAML like the above.

After that, give the permission to pipeline:

enter image description here

Finally, run the pipeline to push artifact to feed:

enter image description here

Each step of this method is very clearly and each time you want to push artifact, you just need to change several settings is ok(Version, Repo that the pipeline based on, artifact name). Create once, use for a long time.


Additional:

How to change the repo that the pipeline based on:

enter image description here

enter image description here

Repository Structure on my side:

enter image description here


Everything of push artifacts:

Publish Nuget packages(NuGet.exe)

Publish Nuget packages(dotnet)

Publish NuGet packages with Azure Pipelines (YAML/Classic)

Bowman Zhu-MSFT
  • 4,776
  • 1
  • 9
  • 10
  • I will keep this in mind. I set up the feed more than a year ago and I wish I could remember how I did it so easily then, but I know I did not have to modify nuget.config. I noticed that the guidelines under "connect to feed" in the portal mention some authentication tools and I have to wonder if my current distribution of VS is missing something I had before related to authentication. I don't know but if that's what accounted for the ease of setting up the feed at the beginning but it would explain my confusion. – RTD Oct 11 '22 at 02:19
  • Although it does not explain my predicament exactly this is a useful answer for another scenario. – RTD Oct 11 '22 at 02:21