10

I am trying to publish a NuGet package to a NuGet feed I created in Azure Devops. I have experience in doing these kind of things (I published on NuGet.org) but for some reason I do not understand, it is not working when I try to do this for my employer.

When I click "Connect To Feed", I see this explanation:

enter image description here

This clearly shows where to put my package path and where to put the source. However, it does not show where to put the API key I generated.

But I gave it a try and typed (after generating the package file):

dotnet nuget push --source "Test" --api-key az ClassLibrary1.1.0.0.nupkg

This was not working (401)

enter image description here

I really do not understand this part of the explanation: "API Key (any string will do)". Why possibly "any string will do". I need a valid API key.... Not "any string".

After that I tried to publish in way I have good experience with (when publishing nuget.org public nuget packages). In this statement, the source and key are clearly specified.

Here is how I did it:

enter image description here

Also that does not work. I got a 401 again.

My API key that should give me access (and thus prevents a 401) should be fine. This is how I generated the API key:

enter image description here

Most likely, there is something wrong with the way I specified my API key, not with the API key itself. So how do I specify it correctly in my command-line statement in order to successfully publish my package?

1 Answer 1

13

There are a few steps you'll have to take before you can push to your NuGet feed locally:

  1. Install the Azure Artifact Credential Provider: https://go.microsoft.com/fwlink/?linkid=2099625
  2. Run dotnet restore --interactive, this will prompt you for credentials
  3. Run dotnet nuget push --source "BackgroundJobs" --api-key anyapikey <package-path>

Note: You can use any API key.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. I am still extreme surprised that an api key argument is expected which in the end can be any value.... But indeed you are right. This works. Just tested in WSL2.
Yeah, it's strange. Microsoft's documentation even indicates it can be anything.
Thank you guys, just been through this one, for anyone else who is going trough the process, please remember to restart VS (if you are using it) after installing the Azure Artifact Credential Provider, otherwise, it will not recognize the plugin. it took me 2 hours to figure this out :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.