NuGet Packages Feed Setup#
First, Create a Personal Access Token (PAT) including the read:packages scope.
You'll need a free GitHub account.
Copy the token for reference. It will look something like:
ghp_yLKCoOLozKbaErgl4mCLDtkEKFw6Uq4D3Yyx
Select Tools > NuGet Package Manager > Package Manager Settings > Package Sources
Click the âž• icon, and fill in:
Name: McLaren Applied GitHub Packages
Source: https://nuget.pkg.github.com/mat-docs/index.json
Click Update to save the changes.
When prompted for credentials, enter your GitHub username and PAT:
From the terminal, replacing "your_username"
and "your_pat"
:
nuget sources Add -Name "McLaren Applied GitHub Packages" -Username "your_username" -Password "your_pat" -Source "https://nuget.pkg.github.com/mat-docs/index.json"
or:
dotnet nuget add source --name "McLaren Applied GitHub Packages" --username "your_username" --password "your_pat" "https://nuget.pkg.github.com/mat-docs/index.json"
In scripted environments, it can be convenient to add the PAT to a NuGet.Config file.
Caution
Do not commit credentials into source control.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="McLarenApplied" value="https://nuget.pkg.github.com/mat-docs/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<!-- DO NOT ADD THIS INTO SOURCE CONTROL -->
<packageSourceCredentials>
<McLarenApplied>
<add key="Username" value="your_username" />
<add key="ClearTextPassword" value="your_pat" />
</MAT>
</packageSourceCredentials>
</configuration>
To add this <packageSourceCredentials>
section from an Azure DevOps YAML build:
steps:
- task: NuGetToolInstaller@1
inputs:
versionSpec: "5.8.0"
- task: DotNetCoreCLI@2
displayName: "dotnet nuget update source (authenticate)"
inputs:
command: custom
custom: nuget
arguments: update source McLarenApplied --username "your_username" --password "your_pat" --store-password-in-clear-text --configfile NuGet.Config
verbosity: "Normal"