Intro

I decided to write this post for anyone struggling to setup and use private nuget feed from Azure DevOps, because in my opinion the microsoft documentation is little bit confusing in this case.

Prerequisities

Creating nuget feed

Creating new feed is straigt forward. Open Azure DevOps, and select Artifacts file in side menu. Then click on + New feed, give the feed new name and click Create.

Missing artefacts?

If you can’t see Artifacts menu item then it’s probably disabled in Project settings. To enable it, open Project settings, also from left sidebar menu, select Overview and in Azure DevOps services section, enable Artifacts switch.

file

Uploading packages to your feed

Great, now we have the feed, but there are no packages, let’s add them. Considering you are still on artifacts page, select your feed from dropdown menu and then click Connect to feed button.

file

Next page differes little bit, depending on your Azure DevOps version, but in either case we need to get our Package source url.
Select nuget.exe from side menu and copy Package Source Url(it ends with .../nuget/v3/index.json).

Latest versions of Azure DevOps

First add your feed to nuget sources:

Install Azure Artifacts credential provider, follow instructions on github or for windows just run from powershell:

You can then check that nuget \plugins directory contains \netcore folder using ls "$env:UserProfile\.nuget\plugins".

Finally go to a directory where your .nupkg file is and run following snippet:

Microsoft Sign in window should automatically pop up.

When you enter your credentials, you should see message Your package was pushed..

Older versions(on premise) Azure DevOps

Edit following snippet with your package source url, credentials and run it:

Previous code will add your feed to nuget sources. Next we need Personal Access Token(PAT). In Azure DevOps, open user settings in top right corner, click on Security and on next page select Personal Access Tokens.

file

Click on + New Token, give it name and expiration, then on bottom click Show all scopes and select Read & write permission under Packaging.

file

Click Create to generate new PAT. Store it securely, we will need it in next step.

Now we need to assing the PAT/Api key to our nuget feed:

You can verify all nuget settings inside %APPDATA%\NuGet\nuget.config, you should see similar configuraton file(note that all sensitive information is encrypted):

Finally lets push our nuget package(Test.1.0.0.nupkg):

After that, you should see Test.1.0.0.nupkg package appear in Azure DevOps.

Consuming your packages from Visual Studio

In Visual Studio right click project Dependencies and select Manage NuGetPackages....

file

In next window select your package source in top right corner(or select All). Finally you sould see your package in browse tab.

Conclusion

That’s it, if you followed this manual you should be able to use your nuget packages from Azure DevOps feed.

Last modified: April 5, 2023
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments