Configuring nuget.config for Azure DevOps Artifacts / VS Code and .net 6
If you are using Azure DevOps and the artifacts feature to store and share your nuget packages, you may struggle with setting it up. This is why I wanted to share how I configured my nuget.config to access the packages from the command line (and VS Code :) )
First of all you need to install the tools and the Azure DevOps credential provider from github. It’s linked from the Azure DevOps GUI. Github Project and Downloads. You should follow one of the installation guides there. I did the manual installation on windows.
Installation of the tools (you should stick with current instructions on github!)
So I created the folder plugins in %UserProfile%/.nuget and I extracted the contents of the plugins subfolder from the provider to that folder. After extraction the path to the target folders is: Microsoft.Nuget.CredentialProvider/plugins and there the two target folders netcore and netfx appear
So my installation looks like this:
You can check the path %UserProfile%/.nuget/plugins/netcore/CredentialProvider.Microsoft it should contain quite a few dll libraries and files now
Update the nuget.config
Open the file %AppData%/Nuget/Nuget.Config
As shown in Azure DevOps Gui add:
Configuration -> Packagesources ->
<add key=”Azure” value=”https to your Azure Artifacts feed” />
Now you are done and can restore and install packages from Azure DevOps via dotnet restore --interactive
Authenticate with a PAT from Nuget.Config
You can add a new section in you Nuget.Config under the main Configuration entry:
<Azure> <!-- Name of the key a few lines earlier -->
<add key=”Username” value=”Some nice name” />
<add key=”ClearTextPassword” value=”A PAT from Azure Devops” />
The Pat should have the custom defined grants “Packaging -> Read”.
See you soon!