Forward debugger ports for dotnet run - #12578
Open
jonathanpeppers wants to merge 1 commit into
Open
Conversation
Route both ComputeRunArguments wait modes through Microsoft.Android.Run, add generic ADB TCP mappings, and preserve legacy Run and _Run behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f13f2ddd-fcd8-4c74-a37a-fdf6855b0d36
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes dotnet run / dotnet watch Android debugger port-forwarding by ensuring the ComputeRunArguments launch path always goes through Microsoft.Android.Run, where ADB port mappings can be established before launching the app (including the WaitForExit=false/non-blocking mode).
Changes:
- Route both
WaitForExit=trueandWaitForExit=falseComputeRunArgumentsexecution throughMicrosoft.Android.Run, using--no-wait/--no-wake-devicefor the non-blocking mode. - Add generic repeatable
--forward-port/--reverse-portoptions toMicrosoft.Android.Run, and haveComputeRunArgumentsemit a forward mapping whenAndroidAttachDebugger=trueandAndroidDebuggerServer=true. - Add a focused regression test asserting that
ComputeRunArgumentsincludes the expected--forward-portarguments (and suppresses legacy--debugger-*args).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildOrderTests.cs | Adds regression coverage to validate ComputeRunArguments emits generic port-forwarding args in both wait and no-wait modes. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets | Updates ComputeRunArguments to consistently invoke Microsoft.Android.Run and pass through forwarding + no-wait/no-wake flags as needed. |
| src/Microsoft.Android.Run/Program.cs | Implements --no-wait, plus repeatable --forward-port / --reverse-port configuration and applies the mappings before app launch. |
Member
Author
|
/review |
Contributor
|
🚀 Android PR Reviewer has started processing this issue comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WaitForExit=trueandWaitForExit=falseComputeRunArgumentspaths throughMicrosoft.Android.RunAndroidSdbTargetPort/AndroidSdbHostPortvalues as a generic ADB forward mapping whenAndroidAttachDebugger=trueandAndroidDebuggerServer=true--forward-portand--reverse-portrunner optionsRun,_Run,RunActivity, Mono debugger, and JDWP behavior unchangedBackground
dotnet runand thedotnet run --no-buildchild launched bydotnet watchexecute the command returned byComputeRunArguments; they do not invoke_Run. The debugger properties therefore reached MSBuild, but the legacy_Runtarget that establishedadb forwardnever executed.This change establishes the requested port mapping in
Microsoft.Android.Runbefore launching the application.WaitForExit=falseuses the same runner with--no-wait, preserving the non-blocking launch behavior while ensuring forwarding works in both modes.CoreCLR debugger configuration remains owned by vscode-maui, which ships the native debugger libraries and configures the runtime. See DevDiv/vscode-maui PR 716837 for that implementation.
A broader cleanup is intentionally deferred to .NET 12: #12577 tracks unifying the
Runtarget behavior, deleting_Run, and removing obsolete Mono-specific launch paths.Validation
Microsoft.Android.Runfornet10.0Microsoft.Android.Sdk.Application.targetsas XMLComputeRunArgumentscoverage for waiting, no-wait, debugger-server, and forwarding behaviorThe full
Xamarin.Android.Build.Testsassembly was not run because this checkout does not contain the locally built Android SDK/reference packs.