Recently, I started using NuGet package hosting in Visual Studio Team Services. I quickly found that in order to consume those packages in Visual Studio Code on my mac, I had to perform a few extra steps outside of simply connecting to the package url, which I’ve outlined here.
- If you haven’t already done so, install the dotnet sdk
- Login to VSTS and navigate to the User menu > Security option:
- Create a Personal Access Token (PAT):
-
- Enter a description for the token
- Set the expiration to 1 year
- Ensure the selected account is correct
- Set either of the following Authorized Scopes:
- Packaging (read and write)
- Packaging (read)
- Click the Create Token button
-
- On the Personal Access Tokens window, copy the PAT value:
- From a terminal, enter the following command:
nuget sources add -Name <YOUR_REPO_NAME> -Source <YOUR_REPO_SOURCE_URL> -UserName <YOUR_EMAIL_ADDRESS> -Password <PAT_VALUE> -StorePasswordInClearText -ConfigFile ~/.nuget/NuGet/NuGet.Config
- After the command completes, you should see the following output:
Package Source with Name: <YOUR_REPO_NAME> added successfully.
After you’ve performed these steps, you should be able to successfully install and restore your custom NuGet packages from your VSTS repo.