Dotnet tool install 401 Unauthorized

Copper Contributor

I'm trying to install the "dotnet-reportgenerator-globaltool" tool via .Net Core custom task.

 

Custom Command: tool

Arguments: install --global dotnet-reportgenerator-globaltool --version 4.0,15

 

Problem: When executing from a directory that contains a nuget.config pointing to a private azure artifacts, I get an error like the following. I don't want to use my feed or need to, but because the nuget.config exists I have no choice. Is there a way I can pass credentials to this command? There is no directory that doesn't inherit the nuget.config :sad:

 

[command]"C:\Program Files\dotnet\dotnet.exe" tool install --global dotnet-reportgenerator-globaltool --version 4.0.15
C:\Program Files\dotnet\sdk\2.2.104\NuGet.targets(114,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/bstglobal/_packaging/BSTWEB/nuget/v3/index.json. [C:\Users\VssAdministrator\AppData\Local\Temp\rkrgqk3i.dkp\restore.csproj]
C:\Program Files\dotnet\sdk\2.2.104\NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\Users\VssAdministrator\AppData\Local\Temp\rkrgqk3i.dkp\restore.csproj]
The tool package could not be restored.

 

 

5 Replies

Hi @smithjohn039,

Thanks for posting your issue here.

However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang

@LanHuang  

Issue Resolved, Thanks for the proper guidance


@LanHuang wrote:

Hi @smithjohn039,

Thanks for posting your issue here.

However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A  forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang


 

How did you solve it

 

Issue Resolved, Thanks for the proper guidance

@LanHuang wrote:

Hi @smithjohn039,

Thanks for posting your issue here.

However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, if you can share it here is another technical question; Is there a user-friendly Windows application available for controlling ceiling fans? Similar to the PC fan control software I use, I'm hoping to find a convenient solution that allows office workers like myself to adjust fan speed for an instant breeze from my desktop, eliminating the need to get up and reach out to the wall outlet's physical controls." Microsoft Q&A.

Best Regards,
Lan Huang

mee to trying to install the "dotnet-reportgenerator-globaltool" tool via .Net Core custom task.

 

Custom Command: tool

Arguments: install --global dotnet-reportgenerator-globaltool --version 4.0,15

 

Problem: When executing from a directory that contains a nuget

  1. Generate a Personal Access Token:
    Go to your Azure DevOps account settings.
    Select "Security" and then "Personal Access Tokens."
    Generate a new token with the necessary scopes, including the ability to read packages.
    Pass the Personal Access Token:
    Modify your nuget.config to include the PAT as the password in the package source URL.
    Example: https://username:email address removed for privacy reasons/bstglobal/_packaging/BSTWEB/nuget/v3/inde...
    Run the Installation Command:
    Run your installation command again, and it should authenticate using the provided PAT.
  2. Use Credential Provider:
    Consider using the NuGet Credential Provider, which can securely store and provide credentials when restoring packages.
  3. Install the Credential Provider:
    Install the NuGet Credential Provider by running nuget.exe install check, NuGet.CredentialProvider.VSS -Source https://api.nuget.org/v3/index.json.
  4. Configure the Credential Provider:
    Configure the credential provider with the necessary credentials (username and PAT) using nuget sources Update -Name <SourceName> -User <Username> -Pass <PAT>.
  5. Run the Installation Command:
    Run your installation command again, and the credential provider should handle authentication.

Ensure that you keep your credentials secure and do not hardcode them in scripts or configuration files for security reasons. Personal Access Tokens, especially, should be treated with care and stored securely.