Repository navigation
Description
Summary
On dev (14d4623588), src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/DefaultVSCredentialServiceProvider.cs constructs the credential service with a constant:
var credentialService = new CredentialService(
new AsyncLazy<IEnumerable<ICredentialProvider>>(() => ...),
nonInteractive: false,Before NuGet/NuGet.Client#7676 this was derived from the VS shell mode — nonInteractive = IsInServerModeAsync(...), with the removed comment "can only interact when VS is not in server mode". NuGet/NuGet.Client#7676 removed the derivation to eliminate the UI-thread switch that deadlocked credential-service initialization (the AsyncLazy conversion in the same area completed that cleanup), and states the rationale: VS's Nexus server mode was removed, VSSM_Server can no longer be returned, the branch was unreachable in supported modes, so the constant preserves the effective value.
Two residual observations, offered as a heads-up rather than a bug:
-
The codebase still carries live server-mode handling:
NuGet.Console/OutputConsole/OutputConsoleProvider.csstill consultsIsInServerModeAsyncfor the cached build-output console. If any VS mode, embedded host, or future automation surface ever setsVSSM_Serveragain, the credential service will now be constructed interactive in exactly the state where the product's own history says auth must be non-interactive (Auth on server must be non-interactive. Auth on client should be interactive. NuGet.Client#3435, fixing Auth in Visual Studio should not always be interactive #9659): "Auth on server must be non-interactive. Auth on client should be interactive."). Nothing would surface that drift: the flag is a literal, so no assertion, log line, or test fires. -
The interactivity decision is now encoded at the construction site, disconnected from the shell state it used to mirror — the coupling between "server mode exists" and "credential service is non-interactive" lives only in the PR description, not in the code.
Repro
Code-level; no runtime needed:
$ git show 14240937a -- src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/DefaultVSCredentialServiceProvider.cs
- // can only interact when VS is not in server mode.
- bool nonInteractive = await VisualStudioContextHelper.IsInServerModeAsync(CancellationToken.None);
var credentialService = new CredentialService(
- nonInteractive: nonInteractive,
+ nonInteractive: false,and the surviving consumer of the same helper:
$ grep -rn "IsInServerModeAsync" src/NuGet.Console/
src/NuGet.Console/OutputConsole/OutputConsoleProvider.cs: ... server mode still a handled state here ...Suggested fix
If server mode is truly unreachable, a derivation without a UI-thread switch keeps the posture self-maintaining and removes the literal:
- capture the shell mode once at initialization, off the hot path (e.g.
VisualStudioContextHelpercaching the value from a single background-thread switch before any credential path needs it), and derivenonInteractivefrom that snapshot; or - keep the constant, but emit a one-time assertion/telemetry event when server mode IS observed in a credential-service construction path, so posture drift becomes observable instead of silent.
Impact framing
Dev-branch observation only (no tag or release branch carries these commits as of 2026-09-21; newest tag v11.0.0 predates the window). Not a vulnerability report — under the stated rationale the constant is behavior-preserving today; the concern is purely that a documented interactivity posture now rests on an external fact (server-mode unreachability) that the code neither checks nor asserts, while a sibling component still treats server mode as a live state.
Activity
nkolev92 commentedon Sep 21, 2026
We should remove all code that references VisualStudioContextHelper.IsInServerModeAsync and that method.
VS is always interactive.