NuGet.config Authentication with Azure DevOps Package Feeds
Goal
Authenticate NuGet to access private Azure DevOps Package Feeds.
Setup Azure DevOps
Add user bustroker.packages.restore@bustroker.onmicrosoft.com as a Reader in your Feed’s Security tab, then generate a Read Package PAT.
Basic Authentication
//nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="BustrokerPackages" value="https://pkgs.dev.azure.com/bustroker/_packaging/Bustroker.Packages./nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<BustrokerPackages>
<add key="Username" value="bustroker.packages.restore@bustroker.onmicrosoft.com" />
<!-- Azure DevOps PAT that can ONLY ReadPackages -->
<add key="ClearTextPassword" value="CLEAR_PAT" />
</BustrokerPackages>
</packageSourceCredentials>
</configuration>
Using Environment Variables
//nuget.config
<packageSourceCredentials>
<BustrokerPackages>
<add key="Username" value="%USER_VARIABLE%" />
<add key="ClearTextPassword" value="%PAT%" />
</BustrokerPackages>
</packageSourceCredentials>
Using Encrypted Password
//nuget.config
<packageSourceCredentials>
<BustrokerPackages>
<add key="Username" value="bustroker.packages.restore@bustroker.onmicrosoft.com" />
<add key="Password" value="ENCRYPTED_PAT" />
</BustrokerPackages>
</packageSourceCredentials>
To encrypt passwords, use the NuGet CLI sources command.