Skip to content

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

Draft
JakeRadMSFT wants to merge 4 commits into
dotnet:mainfrom
JakeRadMSFT:dev/jakerad/workspace-dotnet-host-prerequisite
Draft

WIP - Use C# Dev Kit workspace dotnet for debugger checks#9733
JakeRadMSFT wants to merge 4 commits 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 dotnet host when the installed Dev Kit supports the additive public contract.

  • Feature-detects exports.dotnet?.getWorkspaceDotnetHost without requiring a newer C# Dev Kit.
  • Uses the exact dotnetPath and environment returned for debugger dotnet --info and dotnet --list-runtimes checks.
  • Suppresses competing ambient probing and C# SDK remediation when the service reports blocked.
  • Preserves existing standalone behavior when C# Dev Kit is absent, bypassed by dotnet.preferCSharpExtension, older, not applicable, fails activation, rejects the optional call, or does not settle within the bounded wait.
  • Prevents Dev Kit activation that completes after the bounded fallback from starting late workspace-host remediation.
  • Leaves the existing C# activation flow and debugger launch environment unchanged.

Compatibility

C# Dev Kit state C# debugger behavior
Absent or bypassed with dotnet.preferCSharpExtension Existing configured/ambient discovery
Exports without dotnet, or version 0.1 service without the optional method Existing configured/ambient discovery
Activation or optional method rejects Existing configured/ambient discovery
Optional method does not settle within 90 seconds Existing configured/ambient discovery
Activation completes after the 90-second fallback Optional workspace-host method is not invoked
not-applicable Existing configured/ambient discovery
blocked No competing ambient probe or C# SDK notification
ready Exact returned executable and environment used for debugger prerequisite checks

Producer

The corresponding additive producer is vs-green !780185, currently at 77c0b74d56ed7d789185cc810297345ebcd6fc27 against 64b7aa338a07008a6e10788c8207afa5993f3ed1. Its public WorkspaceDotnetService remains version 0.1, keeps getSdkInfo() and onDidChangeSdkInfo, and optionally adds getWorkspaceDotnetHost() returning ready, blocked, or not-applicable.

Validation

  • Focused compatibility tests: 11 passed
  • TypeScript --noEmit: passed
  • ESLint on all changed files: passed
  • Development extension bundle: passed
  • Focused review of the timeout-guard delta: no further findings
  • Previous head 25d0d68771412ec4c65255011cdb8681a5228022 had an unrelated Linux ZipInstaller temp-cleanup ENOTEMPTY failure; this PR does not change package installation or temporary-directory cleanup

Current gate

The converged head has been pushed. GitHub checks and current-head review for this new head must pass before the PR is marked ready for review.

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.

@JakeRadMSFT JakeRadMSFT changed the title Use C# Dev Kit workspace dotnet for debugger checks WIP - Use C# Dev Kit workspace dotnet for debugger checks Sep 11, 2026
Converge debugger prerequisite checks on the optional workspace dotnet service contract while preserving standalone compatibility.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 11, 2026 06:06
@JakeRadMSFT
JakeRadMSFT marked this pull request as draft September 11, 2026 06:08

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

Guard the activation continuation after the timeout to prevent late competing Dev Kit UI.

Review details

Suppressed comments (1)

src/coreclrDebug/activate.ts:244

  • The timeout only resolves the outer race; it does not stop this activation chain. If activate() is still pending when the 90-second timer wins, a later activation completion will still invoke getWorkspaceDotnetHost() after this function has already fallen back to standalone probing. Since the blocked result is the state associated with opening Workspace Requirements, this can produce the competing Dev Kit UI after the C# SDK notification; guard the continuation after timeout or use a cancellable producer contract.
        return await Promise.race([
            Promise.resolve()
                .then(async () => await csharpDevKit.activate())
                .then(async (exports) => await exports?.dotnet?.getWorkspaceDotnetHost?.())
                .catch(() => undefined),
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

JakeRadMSFT and others added 2 commits September 10, 2026 23:21
Prevent a Dev Kit activation that finishes after the bounded fallback from starting workspace host resolution and competing remediation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Forward the selected workspace host environment to vsdbg-ui and prevent an ambient DOTNET_ROOT from overriding the selected host.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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