sdk: dotnet tool restore interactive doesn't prompt for DeviceFlow since .NET 6 SDK
Describe the bug
If I use .NET 5 SDK, and call dotnet tool restore --interactive, I get presented with the DeviceFlow authentication flow from NuGet’s MicrosoftCredentialProvider plugin (https://github.com/microsoft/artifacts-credprovider).
I get something like this:
[CredentialProvider]DeviceFlow: https://XXX.pkgs.visualstudio.com/_packaging/XXX/nuget/v3/index.json
[CredentialProvider]ATTENTION: User interaction required.
**********************************************************************
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXXX to authenticate.
**********************************************************************
However, if I need the same thing in .NET 6 SDK (using 6.0.100), the output is silent, I don’t receive any prompt on the output.
I found a workaround to add --verbosity minimal in the command parameters. But without this, it seems that the default verbosity is quiet which doesn’t include the interactive auth flow prompt.
In .NET 5, the verbosity switch didn’t have any effect for dotnet tool restore, I even created issue #16535. but in .NET 6, suddenly, the verbosity is working. It’s just that the default verbosity is too quiet and is missing the important prompts.
To Reproduce
- ensure that the tool packages to be restored aren’t in NuGet cache
- ensure that you use feed that needs MicrosoftCredentialProvider auth (https://github.com/microsoft/artifacts-credprovider), I’m using Azure DevOps Artifacts
- ensure you don’t have any MicrosoftCredentialProvider token already in cache
- call
dotnet tool restore --interactive - expected: prompt for device login
- actual: no output, program keeps running and waiting for the auth
Further technical details
.NET SDK (reflecting any global.json):
Version: 6.0.100
Commit: 9e8b04bbff
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 48
- Comments: 23 (1 by maintainers)
Actually, our workaround was similar, even
--verbosity minimalworked.It’s as if the default verbosity is
quiet, which is too quiet.I’ve had the same issue. As a workaround use the -v diag parameter, at least this worked for me
Any plans to fix this? My team is also getting this problem since upgrading to .NET 6, the
--verbosity minimalworks as a workaround, but it’s a bad dev experience that causes devs to waste time wondering what’s going on before finding this workaround@baronfel - This looks like a regression in .NET 6 and higher. Would it be possible for someone to take a look?
I think I can see in the code why this happens.
This bug fix was added https://github.com/dotnet/sdk/issues/10024 to ensure that it sets verbosity minimal (much like the example above).
https://github.com/dotnet/sdk/blob/a30e465a2e2ea4e2550f319a2dc088daaafe5649/src/Cli/dotnet/commands/dotnet-tool/install/ProjectRestorer.cs#L85
however, where the commands are registered, this is set and then overwritten when the verbosity is registered on the next line. Maybe swapping the lines over would work?
https://github.com/dotnet/sdk/blob/2c98ff1381def385256788cfcbaefb3ac32f5778/src/Cli/dotnet/commands/dotnet-tool/restore/ToolRestoreCommandParser.cs#L41
This is the same in the Restore and Update
Hi, do you have ETA when it will be fixed?
I’m getting the same issue, thanks @tompazourek for the workaround.
I’ve experienced this as well on .NET 7.
Running
dotnet tool install -g Microsoft.dotnet-interactivein a cmd prompt yields this error, reflecting a package source I have to an Azure DevOps artifacts feed:For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool
Re-running it with
dotnet tool install -g Microsoft.dotnet-interactive --verbosity minimal --interactiveprompted me to visit https://microsoft.com/devicelogin and provide a code, which after logging in successfully completed the restore and installed the tool (and I later got an email that a personal access token has been issued on my behalf for the vso.drop_write scope.I’m pretty sure something like this is the basis for the issue I’m having with using .NET interactive notebooks in VS Code in that I cannot install the NuGet packages because it cannot authenticate to my private Artifact feeds.
https://github.com/dotnet/sdk/issues/22987#issuecomment-1280977262
The bot closed this however any thoughts on my comment which points to what I believe is the issue in the code that is in this code base?
I have started having this issue as well but i am not sure how this has just started, i have had dotnet 6 installed for awhile now and have not had issues.
dotnet tool update -g toolname --interactiveAny updates?
Same issue here, used @cervesus workaround
dotnet tool restore -v n --interactive.Details:
6.0.101Pop!_OS 22.04 LTS (Ubuntu 22.04)Intel-64@ThisWholeDev Maybe the NuGets you were restoring before were already in the NuGet cache. Or maybe the session token was already present in the CredentialProvider storage (see https://github.com/microsoft/artifacts-credprovider#session-token-cache-locations). It has an expiration time, so it only does the auth flow from time to time, not always.
But yeah, your output looks like something I’m getting too.