How do I authenticate to NuGet?
Interactive authentication option
- install the credential provider
wget -qO- https://aka.ms/install-artifacts-credprovider.sh | bash
this will place the nuget configuration here: /home/<user>/.nuget
- restore packages interactively
dotnet restore --interactive (will now ask you to do a device login)
this will prompt you for a device login flow
Configuration file option
Configure the nuget.config
file as follows:
placeholder
$NUGET_UID}
is a user login and${NUGET_PWD}
is an associated PAT which has access to packages
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value=".\packages" />
</config>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet.myget.org roslyn" value="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
<add key="my-custom-production" value="https:<something>/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<my-custom-production>
<add key="Username" value="${NUGET_UID}" />
<add key="ClearTextPassword" value="${NUGET_PWD}" />
</my-custom-production>
</packageSourceCredentials>
</configuration>