Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet restore --interactive: 401 Unauthorized on Windows with Azure DevOps feed

See original GitHub issue

Steps to reproduce

dotnet restore always fails on Windows when connecting to a private feed hosted on ADO.

>dotnet restore --interactive
  Restoring packages for ....csproj...
  Restoring packages for ...csproj...
C:\Program Files\dotnet\sdk\2.2.104\NuGet.targets(114,5): error : Unable to load the service index for source [....sln]
C:\Program Files\dotnet\sdk\2.2.104\NuGet.targets(114,5): error :   Response status code does not indicate success: 401 (Unauthorized). [....sln]

Expected behavior

Running dotnet restore --interactive should prompt for code auth, like it does on macOS. Alternatively, running dotnet restore should behave like nuget restore does, and prompt for credentials allowing you to enter a PAT.

Actual behavior

On Windows 10, running dotnet restore --interactive or dotnet restore will always fail when connecting to a private feed on ADO.

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json): Version: 2.2.104 Commit: 73f036d4ac

Runtime Environment: OS Name: Windows OS Version: 10.0.17763 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.2.104\

Host (useful for support): Version: 2.2.2 Commit: a4fd7b2c84

.NET Core SDKs installed: 2.1.4 [C:\Program Files\dotnet\sdk] 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.402 [C:\Program Files\dotnet\sdk] 2.1.500 [C:\Program Files\dotnet\sdk] 2.1.502 [C:\Program Files\dotnet\sdk] 2.1.503 [C:\Program Files\dotnet\sdk] 2.2.102 [C:\Program Files\dotnet\sdk] 2.2.104 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

dylankcommented, Apr 3, 2019

Turns out I had the cred provider plugin already installed on macOS, which is why --interactive was working.

For anyone interested reading this, Nikolche let me know that Microsoft decided not to put the plugin in dotnet.exe because there were concerns that shipping auth integration to Azure DevOps within the sdk would’ve been unfair to other feed providers. To resolve your 401 issues you need to install the auth plugin manually that Nikolche mentioned:

Grab the plugin from Install into ~/.nuget/plugins/netcore

Full instructions:

jgn-eppcommented, Feb 12, 2020

I wish this was more clear in some way; maybe dotnet could give a warning that --interactive will not work without some credential manager instead of doing nothing?

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet restore fails with error 401:Unauthorized while ...
The Personal Access Token has adequate permission to access Azure DevOps Artifacts Nuget Feed. Both fails with following error details within ...
Read more >
"dotnet restore --interactive" doesn't work with Azure Artifacts
error: Response status code does not indicate success: 401 (Unauthorized). I solved the problem in my Windows dev environment creating an Azure ......
Read more >
Getting 401 When Restoring NuGet: Azure DevOps Private ...
This is about a common error that occurs in Visual Studio when you are trying to load a project that includes private NuGet...
Read more >
Fixing NuGet error: Unable to load the service index for source
Running a package restore in dotnet should be easy. Sometimes, with NuGet, we bump into ... Here's a workaround when we get Unauthorized...
Read more >
Publish and restore packages with dotnet CLI - Azure
With Azure Artifacts, you can publish and restore your NuGet packages to/from your feed and share them with others based on your feed's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found