Search code examples
.netmacosvisual-studio-codeazure-devopsdotnet-cli

How to authenticate via dotnet-cli to install a private package source on MacOS?


I am trying to build and run a .NET project in VSCode with extension c#Devkit on my MacOS.

As described the official microsoft documents I created nuget.config file to the root directory to get packages from our azure devops artifacts.

This is how my nuget.config looks like

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="Custom.Framework" value="https://pkgs.azure.com/example/nuget/v3/index.json" />
  </packageSources>
  <packageSourceCredentials>
    <Custom.Framework>
        <add key="Username" value="[email protected]" />
        <add key="ClearTextPassword" value="my-clear-password" />
    </Custom.Framework>
  </packageSourceCredentials>
</configuration>

Values here are just used to illustrate how nuget.config file appears but even if I am completely sure that my username and password are correct in my local machine I can't get success from the command below.

dotnet restore command

It outputs

Response status code does not indicate success: 401 (Unauthorized).

I am not sure how should I build and run this project on my MacOS.


Solution

  • I had created a personal access token before I switched to VSCode. For Azure Devops I opened up the Personal Access Token menu and see my PATs. Delete them and create an another one. Changed the value for "ClearTextPassword" with the password generated by PAT that I just created.

    Then it worked for me!