Skip to content

Use C# Dev Kit workspace dotnet for debugger checks - #9733

Open
JakeRadMSFT wants to merge 1 commit into
dotnet:mainfrom
JakeRadMSFT:dev/jakerad/workspace-dotnet-host-prerequisite
Open

Use C# Dev Kit workspace dotnet for debugger checks#9733
JakeRadMSFT wants to merge 1 commit into
dotnet:mainfrom
JakeRadMSFT:dev/jakerad/workspace-dotnet-host-prerequisite

Conversation

@JakeRadMSFT

@JakeRadMSFT JakeRadMSFT commented Sep 4, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #9732 by making debugger prerequisite discovery consume C# Dev Kit's authoritative Workspace Requirements host when the installed Dev Kit supports the new optional contract.

  • Extends C#'s local CSharpDevKitExports shape with optional getWorkspaceDotnetHost().
  • Reuses the existing non-blocking Dev Kit activation callback; C# activation does not await Dev Kit activation.
  • Defers only debugger prerequisite completion, with a bounded 90-second wait and handled rejection paths.
  • Uses the exact selected executable and environment for dotnet --info, dotnet --list-runtimes, architecture selection, and debugger DOTNET_ROOT.
  • Suppresses C#'s competing SDK notification when Workspace Requirements reports blocked.
  • Preserves current ambient/configured discovery for absent, bypassed, old, failed, or not-applicable Dev Kit.

Compatibility matrix

C# Dev Kit state Behavior
Absent Existing standalone C# discovery and notification behavior
Bypassed with dotnet.preferCSharpExtension Existing standalone C# behavior; Dev Kit is not activated for this decision
Old exports without getWorkspaceDotnetHost() Existing standalone fallback; no minimum Dev Kit version
Activation rejects Handled bounded fallback to standalone behavior
Activation does not settle within the bound C# suppresses competing remediation rather than racing Workspace Requirements
New export reports blocked No ambient probe and no duplicate C# SDK notification
New export reports ready Exact returned executable/environment used for debugger prerequisite probes
New export reports not-applicable Existing standalone fallback

Activation safety

C# continues to call Extension.activate() without synchronously awaiting it from the C# activation path. The resulting promise is passed only to debugger prerequisite completion. This allows C# activation to return, lets Dev Kit finish its existing C#→Dev Kit activation cycle, handles rejection/timeouts, and memoizes the decision per activation.

Validation

  • TypeScript compile: passed (tsc --noEmit)
  • ESLint on all changed files: passed
  • OmniSharp unit suite: 39 suites passed; 410 tests passed; 1 skipped
  • Focused compatibility tests: 9 passed
  • Development package build: passed
  • Combined real VS Code UI session with no ambient dotnet on PATH: Workspace Requirements opened in blocked state and the notification center did not contain The .NET SDK cannot be located

Follow-up producer change

The corresponding optional C# Dev Kit export is implemented in https://devdiv.visualstudio.com/DevDiv/_git/vs-green/pullrequest/778204 so this C# change remains safe to ship first. Until that producer version is installed, feature detection follows the old-export fallback row above.

Feature-detect the optional C# Dev Kit workspace host export and defer only the debugger prerequisite decision. Preserve standalone discovery for absent, bypassed, old, or failed Dev Kit versions while suppressing competing remediation when Workspace Requirements is blocked.
@JakeRadMSFT

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 9733 in repo dotnet/vscode-csharp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes debugger prerequisite discovery and activation-time behavior (including timeouts and environment shaping) across multiple entry points and warrants final human validation across platforms and Dev Kit states.

Pull request overview

This PR updates the C# extension’s debugger prerequisite discovery to optionally consume C# Dev Kit’s authoritative “Workspace Requirements” selected dotnet host (when available), ensuring the debugger uses the exact executable/environment selected for the workspace and avoiding duplicate/competing SDK remediation messaging.

Changes:

  • Extend CSharpDevKitExports with an optional getWorkspaceDotnetHost() contract and add a resolver with bounded waiting/fallback behavior.
  • Plumb the resolved workspace dotnet host through CoreCLR debugger activation/install checks and debug adapter launch configuration (including DOTNET_ROOT).
  • Add unit coverage for workspace-host resolution behavior and for passing a selected dotnet + environment into dotnet --info / --list-runtimes.
File summaries
File Description
test/omnisharp/omnisharpUnitTests/coreclrDebug/workspaceDotnetHost.test.ts Adds unit tests validating bounded Dev Kit export resolution and fallback/blocked behaviors.
test/omnisharp/omnisharpUnitTests/coreclrDebug/getDotnetInfo.test.ts Adds unit test validating exact executable/env propagation for dotnet --info / --list-runtimes.
src/shared/utils/getDotnetInfo.ts Adds optional overrides for dotnet executable path and environment, and applies them consistently across probes.
src/main.ts Threads the Dev Kit exports promise through to the CoreCLR debugger activation path.
src/csharpDevKitExports.ts Defines WorkspaceDotnetHost and adds optional getWorkspaceDotnetHost() export.
src/coreclrDebug/workspaceDotnetHost.ts New resolver that waits (bounded) for Dev Kit activation/host selection and maps it to C#’s needs.
src/coreclrDebug/util.ts Extends .NET CLI check to accept an explicit dotnet executable and environment.
src/coreclrDebug/activate.ts Uses resolved workspace host for debugger install prerequisites and debug adapter execution environment decisions.
src/activateRoslyn.ts Returns Dev Kit exports as a promise so downstream components can defer specific work without awaiting activation.
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use C# Dev Kit selected workspace dotnet host for debugger prerequisite checks

2 participants