Skip to content

Fix MAUI iOS simulator launch in VS Code#17857

Merged
adamint merged 23 commits into
microsoft:mainfrom
adamint:dev/adamint/issue17853-maui-ios-debug
Jun 20, 2026
Merged

Fix MAUI iOS simulator launch in VS Code#17857
adamint merged 23 commits into
microsoft:mainfrom
adamint:dev/adamint/issue17853-maui-ios-debug

Conversation

@adamint

@adamint adamint commented Jun 2, 2026

Copy link
Copy Markdown
Member

Description

Fixes #17853

This makes Aspire's MAUI resources debuggable from the VS Code extension instead of falling back to a plain dotnet run terminal launch. The useful user-facing path is: start the AppHost under the Aspire debugger, start a MAUI platform resource from the Aspire tree/dashboard flow, and get the MAUI extension's normal debugger behavior with the right target selected.

The PR now covers Mac Catalyst, Windows, iOS simulator/device metadata, and Android emulator/device metadata. Android also avoids the bad stopped-emulator path where we passed -p:AdbTarget=-s <avd-name> too early and the MAUI build failed with XA0010: Selected device is not running; for stopped emulators we select the MAUI active target and let the MAUI extension launch/resolve the emulator.

User-facing usage

Existing MAUI AppHost code keeps the same shape:

var maui = builder.AddMauiProject("mauiapp", "../MauiApp/MauiApp.csproj");

maui.AddMacCatalystDevice("mobile-mac");
maui.AddiOSSimulator("mobile-ios");
maui.AddAndroidEmulator("mobile-android-emulator");
maui.AddWindowsDevice("mobile-windows");

When the VS Code MAUI extension is installed, Aspire now emits structured MAUI launch metadata through DCP and the VS Code extension maps that to a type: "maui" debug configuration. IDEs that do not advertise support for the maui launch type still get the process fallback path, so this should not break Visual Studio or other IDEs.

Implementation notes:

  • MAUI platform resources emit type: "maui" launch metadata with project path, target framework, platform, target kind, device/runtime metadata, and relevant MSBuild properties.
  • The VS Code extension contributes the MAUI debug bridge only when ms-dotnettools.dotnet-maui is installed.
  • The bridge preserves generated MAUI MSBuild properties, filters Aspire debug infrastructure environment variables, redacts MAUI environmentVariables from debug config logs, and stops late-started child MAUI sessions if the parent Aspire session is disposed.
  • The E2E bridge was split out of extension.ts, and the extracted openInIntegratedBrowser command now preserves the { url } result expected by the E2E tests.

Validation:

  • corepack yarn run compile-tests
  • yarn run unit-test -- --config .vscode-test-short.mjs --grep "MAUI Debugger Extension Tests|E2E launch profile"
  • yarn run unit-test -- --config .vscode-test-short.mjs
  • corepack yarn run compile
  • corepack yarn run lint
  • corepack yarn run compile-e2e
  • dotnet test --project tests/Aspire.Hosting.Maui.Tests/Aspire.Hosting.Maui.Tests.csproj --no-launch-profile -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
  • dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-method "*.MauiProjectWithExecutableAnnotationAndSupportedLaunchConfiguration_RunsInIdeWithLaunchMetadata" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

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

Ensure MAUI iOS simulator resources advertise an SDK-run project launch configuration for VS Code so they run through dotnet run instead of direct CoreCLR DLL launch. Preserve ordinary NoDebug project launch behavior and honor project launch configuration producers in DCP.

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

github-actions Bot commented Jun 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 -- 17857

Or

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

adamint and others added 4 commits June 2, 2026 19:19
Use the existing project launch mode and MAUI iOS run arguments to route simulator resources through dotnet run instead of adding a new IDE protocol field.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reuse the same debug configuration wiring for MAUI SDK-run launches and the existing Blazor WebAssembly dotnet run fallback while keeping their argument builders separate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Share the base dotnet run argument construction and avoid reparsing MAUI SDK-run properties while detecting iOS launches.

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

@adamint adamint left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reviewed with four dedicated passes. I did not find any new, non-duplicate high-confidence issues to raise.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 15, 2026 20:40

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.

Pull request overview

This PR fixes MAUI iOS simulator resource launch failures in VS Code by having the simulator resource opt out of IDE execution (via a non-"project" launch configuration type), so DCP runs it as a normal process using the ExecutableAnnotation-provided command (dotnet run). The VS Code extension no longer attempts to debug the simulator as a CoreCLR process.

Changes:

  • MAUI iOS simulator resources now register a "maui-ios-simulator" debug support type that VS Code does not claim support for, causing DCP to fall through to process execution with the resource's own dotnet run command
  • ExecutableCreator now honors ExecutableAnnotation on project resources (for command and working directory), and injects standard Aspire options (--configuration, --no-launch-profile) into existing dotnet run args
  • The VS Code extension defers dotNetService creation until it's actually needed and extracts a shared configureDotNetRunDebugConfiguration helper
Show a summary per file
File Description
src/Aspire.Hosting.Maui/MauiiOSExtensions.cs Adds WithDebugSupport with "maui-ios-simulator" type so VS Code skips IDE execution
src/Aspire.Hosting/Dcp/ExecutableCreator.cs Honors ExecutableAnnotation for command/working directory, adds AddDotnetRunArgsForExecutableAnnotatedProject helper, refactors ApplyProjectLaunchConfiguration
extension/src/debugger/languages/dotnet.ts Defers dotNetService creation, extracts configureDotNetRunDebugConfiguration helper
extension/src/test/dotnetDebugger.test.ts Adds test verifying ordinary project NoDebug mode uses compiled DLL path
tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs Adds tests for custom debug support producer and ExecutableAnnotation process execution
tests/Aspire.Hosting.Maui.Tests/MauiPlatformExtensionsTests.cs Adds test verifying iOS simulator opts out of project IDE launch while keeping SDK run args

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 0

adamint and others added 2 commits June 15, 2026 17:14
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 15, 2026 21:16

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.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new

@github-actions

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.

@adamint adamint marked this pull request as ready for review June 16, 2026 15:24

@karolz-ms karolz-ms 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.

Looks good but please address my suggestion before merging

Comment thread src/Aspire.Hosting/Dcp/ExecutableCreator.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

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.

adamint and others added 2 commits June 19, 2026 17:56
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e-17857-20260615

# Conflicts:
#	extension/src/extension.ts
#	src/Aspire.Hosting/Dcp/ExecutableCreator.cs
#	tests/Aspire.Hosting.Maui.Tests/MauiPlatformExtensionsTests.cs

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.

Copilot's findings

  • Files reviewed: 30/31 changed files
  • Comments generated: 1

Comment thread extension/src/testing/e2eStateFileBridge.ts Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

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.

@github-actions

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.

@github-actions

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.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 23:13

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.

Copilot's findings

  • Files reviewed: 30/31 changed files
  • Comments generated: 0 new

@github-actions

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.

@github-actions

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.

@github-actions

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.

adamint and others added 3 commits June 19, 2026 22:03
Return the resolved endpoint URL from the E2E control bridge instead of echoing the optional command URL input. This lets resource-scoped openInIntegratedBrowser calls report the URL they actually opened.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve the current main termination-refresh behavior in the refactored extension entry point before merging main.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@adamint adamint enabled auto-merge (squash) June 20, 2026 02:06
Copilot AI review requested due to automatic review settings June 20, 2026 02:06

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.

Copilot's findings

  • Files reviewed: 30/31 changed files
  • Comments generated: 1

Comment thread extension/src/debugger/languages/maui.ts Outdated
adamint and others added 2 commits June 19, 2026 22:15
Remove an unused resolveDefaultDevice local that was left behind from an earlier candidate-selection flow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 20, 2026 02:37

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.

Copilot's findings

  • Files reviewed: 30/31 changed files
  • Comments generated: 1

Comment thread extension/src/debugger/languages/maui.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

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.

@adamint adamint merged commit af50564 into microsoft:main Jun 20, 2026
678 of 681 checks passed
@github-actions github-actions Bot added this to the 13.5 milestone Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VS Code Aspire debug uses CoreCLR debugger for MAUI iOS simulator resource

3 participants