Skip to content

Fix unpackaged WinUI debugging in VS Code - #19877

Merged
Ella Hathaway (ellahathaway) merged 5 commits into
mainfrom
ellahathaway-fix-winui3-debug-crash
Sep 3, 2026
Merged

Fix unpackaged WinUI debugging in VS Code#19877
Ella Hathaway (ellahathaway) merged 5 commits into
mainfrom
ellahathaway-fix-winui3-debug-crash

Conversation

@ellahathaway

@ellahathaway Ella Hathaway (ellahathaway) commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

Unpackaged WinUI 3 project resources crash in Microsoft.UI.Xaml.Application.Start() when debugged through the Aspire VS Code extension because the extension launches the managed TargetPath DLL. That makes vsdbg host WinUI startup in dotnet.exe, which consistently faults with 0xC000027B.

This change detects unpackaged WinUI projects from evaluated MSBuild properties and launches their generated apphost executable (RunCommand) instead. The AppHost and resource keep their existing Aspire parent/child debug topology and lifecycle behavior.

User-facing usage

No project configuration changes are required. Existing unpackaged WinUI resources can keep a normal Project launch profile:

builder.AddProject<Projects.WinUIApp>("winui");

The extension now resolves that resource to the generated .exe while retaining debugger attach, launch-profile arguments, environment variables, and cleanup behavior.

The change also adds a blocking Windows extension E2E shard. It generates a minimal unpackaged WinUI app using the package version from the reported repro, installs pinned C# debugger prerequisites, and requires an Application.OnLaunched readiness marker. Reaching that marker proves startup passed the original Application.Start failure point.

Validation:

  • Reproduced with Aspire VS Code extension 1.21.0, C# 2.140.9, and Windows App SDK 1.8.260209005: Event ID 1000, 0xC000027B, Microsoft.UI.Xaml.dll, faulting dotnet.exe.
  • Verified the same parented debugger topology stays healthy when the generated WinUI apphost .exe is launched.
  • extension/build.ps1
  • 68 focused Dotnet debugger tests
  • corepack yarn run compile-tests
  • corepack yarn run compile-e2e
  • corepack yarn run lint
  • corepack yarn run compile
  • Full PR CI, including VS Code extension E2E (Windows, winui-debug)

Fixes #19091

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Launch unpackaged WinUI project resources through their generated apphost executable so vsdbg does not host XAML startup in dotnet.exe. Add focused unit coverage and a pinned Windows extension E2E shard.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: dc450e2e-3277-4c6f-adb2-47f8344c0c59
Copilot AI balanced review requested due to automatic review settings September 2, 2026 20:52
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 19877

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 19877"

@github-actions

This comment has been minimized.

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.

🟡 Changes recommended

The apphost selection can skip a required rebuild when the DLL is missing, and the new E2E timeout is undersized.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes unpackaged WinUI debugging by launching the generated apphost executable instead of the managed DLL.

Changes:

  • Evaluates additional MSBuild launch properties to detect unpackaged WinUI projects.
  • Adds unit and Windows E2E regression coverage.
  • Adds a pinned, blocking WinUI E2E workflow shard.
File summaries
File Description
extension/src/debugger/languages/dotnet.ts Selects the WinUI apphost executable.
extension/src/test/dotnetDebugger.test.ts Tests MSBuild property parsing and launch selection.
extension/src/test-e2e/winUiDebug.e2e.test.ts Verifies WinUI reaches OnLaunched.
extension/scripts/run-e2e.js Generates and configures the WinUI fixture.
.github/workflows/extension-e2e-tests.yml Adds the Windows WinUI shard and debugger prerequisites.
extension/src/test/e2eLaunchProfile.test.ts Validates the new workflow wiring and pins.
extension/CONTRIBUTING.md Documents running and understanding the shard.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread extension/src/debugger/languages/dotnet.ts Outdated
Comment thread extension/src/test-e2e/winUiDebug.e2e.test.ts Outdated
Comment thread extension/scripts/run-e2e.js
Check both the generated apphost executable and its managed target before skipping the project build.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: dc450e2e-3277-4c6f-adb2-47f8344c0c59
Copilot AI review requested due to automatic review settings September 2, 2026 22:00
@github-actions

This comment has been minimized.

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.

🟡 Changes recommended

The WinUI E2E suite timeout remains shorter than its aggregate waits, creating a concrete CI flake risk.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Raise the scenario timeout above its composed waits so phase-specific diagnostics fire first, and pin the budget in the E2E infrastructure test.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: dc450e2e-3277-4c6f-adb2-47f8344c0c59
Copilot AI review requested due to automatic review settings September 2, 2026 22:09
@github-actions

This comment has been minimized.

Use a shared diagnostic for debugger-backed shards now that WinUI and Azure Functions both install the .NET debugger dependencies.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: dc450e2e-3277-4c6f-adb2-47f8344c0c59

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.

🟢 Approval recommended

The implementation is scoped, preserves existing launch behavior, and includes focused unit and E2E regression coverage.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI review requested due to automatic review settings September 2, 2026 22:16
@github-actions

This comment has been minimized.

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.

🟢 Approval recommended

The targeted implementation preserves existing launch behavior and includes focused unit and blocking Windows E2E coverage.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Comment thread .github/workflows/extension-e2e-tests.yml
Comment thread extension/scripts/run-e2e.js
Comment thread extension/src/debugger/languages/dotnet.ts
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 3, 2026 18:56
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Tests selector

1 / 99 PR test projects · 2 PR jobs · 0 advisory-only targets, from 6 changed files.

Selected PR test projects (1 / 99)

Infrastructure.Tests

Selected PR jobs (2)

extension-e2e, extension-unit

Advisory workflow impact (0)

none


How these were chosen — grouped by what changed

📄 .github/workflows/extension-e2e-tests.yml (changed)
1 directly: Infrastructure.Tests

Job reasons

Job Triggered by
extension-e2e .github/workflows/extension-e2e-tests.yml, extension/scripts/run-e2e.js, extension/src/debugger/languages/dotnet.ts, extension/src/test-e2e/winUiDebug.e2e.test.ts, extension/src/test/dotnetDebugger.test.ts, extension/src/test/e2eLaunchProfile.test.ts
extension-unit extension/scripts/run-e2e.js, extension/src/debugger/languages/dotnet.ts, extension/src/test-e2e/winUiDebug.e2e.test.ts, extension/src/test/dotnetDebugger.test.ts, extension/src/test/e2eLaunchProfile.test.ts

Selection computed for commit edb45fb.

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.

🟢 Approval recommended

The targeted fix is covered by focused unit tests and a blocking Windows regression shard.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@eerhardt Eric Erhardt (eerhardt) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@ellahathaway
Ella Hathaway (ellahathaway) merged commit 3eebed7 into main Sep 3, 2026
150 of 153 checks passed
@ellahathaway
Ella Hathaway (ellahathaway) deleted the ellahathaway-fix-winui3-debug-crash branch September 3, 2026 22:47
@github-actions github-actions Bot added this to the 13.6 milestone Sep 3, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #1616

Generated by PR Documentation Check · auto · 38.8 AIC · ⌖ 8.27 AIC · ⊞ 19.7K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1616 targeting release/13.6.

Triggered signal: pr_body_has_user_facing_section (evidence: PR body's "User-facing usage" section describing the unpackaged WinUI 3 apphost-executable launch fix). Added a note under Language coverage in src/frontend/src/content/docs/get-started/aspire-vscode-extension.mdx explaining that unpackaged WinUI 3 resources are launched via their generated apphost executable instead of the managed DLL, with no project configuration changes required.

Note

This draft PR needs human review before merging.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

⚠️ CI Failure Analysis: Mixed Failures

The CI build contains both transient and non-transient failures.

Failed jobs:

  • Tests / No-package tests (regular, Aspire.Hosting.Radius.Tests, Hosting.Radius, Hosting.Radius, tests/Asp... / Hosting.Radius (windows-latest) — The failing test SealedSecretApplyStepTests.WaitForSealedSecretSynced_StatusMatchesButSecretAbsent_KeepsWaitingThenTimesOut is in the Aspire.Hosting.Radius.Tests project, an area not touched by this PR (which only modifies VS Code extension files and its e2e workflow). The assertion failure (Expected: True, Actual: False) on a wait-for-sync-then-timeout test is consistent with a timing-sensitive/flaky test unrelated to the PR changes. (flaky-test)
  • Tests / Polyglot SDK Validation / TypeScript SDK Validation (Node 22.x) — PR does not touch the polyglot SDK or TypeScript SDK validation code paths; job logs were unavailable to fetch, but the failure is unrelated to PR-changed files (only extension debugger/e2e files and workflow changed). (flaky-test)
  • Tests / Polyglot SDK Validation / TypeScript SDK Validation (Node 24.x) — Same as Node 22.x job: unrelated to PR-changed files, both Node matrix legs failed simultaneously suggesting a shared unrelated/environmental cause rather than a PR-code issue. (flaky-test)
  • Tests / Run VS Code extension E2E tests / VS Code extension E2E (Linux, launch-profiles) — This PR directly modifies extension/scripts/run-e2e.js, extension/src/debugger/languages/dotnet.ts, extension/src/test-e2e/winUiDebug.e2e.test.ts (new), and the extension-e2e-tests.yml workflow itself. The 'launch-profiles' e2e job failing is directly tied to code and test infrastructure the PR changed. (code-issue)
  • Tests / Run VS Code extension E2E tests / VS Code extension E2E (Windows, launch-profiles) — Same reasoning as the Linux launch-profiles job: directly exercises the debugger/e2e code paths this PR changed (dotnet.ts, run-e2e.js, new winUiDebug.e2e.test.ts). (code-issue)
  • Tests / Polyglot SDK Validation / Polyglot Validation Results — This is an aggregation/summary job that fails when any TypeScript SDK Validation matrix leg fails; it is downstream of the unrelated TypeScript SDK Validation failures, not an independent code issue. (flaky-test)

The CI will not be automatically rerun. Please review the failures above.

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

Projects

None yet

4 participants