Skip to content

[Xamarin.Android.Build.Tasks] Skip RID-inner device checks - #13304

Merged
jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers-repeated-device-checks
Oct 28, 2026
Merged

jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers-repeated-device-checks

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

A small C# change followed by dotnet run -bl repeated <BootAndroidEmulator/> in publish-only RID inner builds, although <GetPrimaryCpuAbi/> already skips its device query there.

Skip the _EnsureDeviceBooted target when $(_ComputeFilesToPublishForRuntimeIdentifiers) is true. Keep the outer-build ABI hook and the explicit deployment/run-argument dependencies. Add three regression cases to BuildOrderTests for inner builds, outer builds with an explicit RID and ADB target, and an empty device selection.

A before/after incremental deploy and launch on an online Pixel 10 confirmed:

Phase Before After
MT command-line build 2 calls 1 call
Ordinary CLI API deployment and launch preparation 3 calls 2 calls
Total 5 calls 3 calls

Both runs compiled one C# change and launched successfully, confirmed by process-specific logcat markers. The MT build used -m -mt -nr:false -warnaserror:MSB4286,MSB4287,MSB4288 with no MT safety warnings or errors. The ordinary CLI API calls are not counted as MT work. The probe used this worktree's rebuilt SDK 12.0.100-alpha.1.26523.103; no elapsed-time improvement is claimed.

Validation:

  • .\dotnet-local.cmd build Microsoft.Android.slnx -nodeReuse:false -v:quiet — passed after rebase, with existing warnings.
  • .\dotnet-local.cmd build Microsoft.Android.slnx -t:PackDotNet -nodeReuse:false -v:quiet — passed after rebase, with existing warnings.
  • .\dotnet-local.cmd test bin\TestDebug\net10.0\Xamarin.Android.Build.Tests.dll --filter FullyQualifiedName~BuildOrderTests — all 7 passed after rebase, with TEST_ANDROID_JDK_PATH=D:\android-toolchain\jdk-21.
  • .\dotnet-local.cmd test tests\Xamarin.Android.Tools.AndroidSdk-Tests\Xamarin.Android.Tools.AndroidSdk-Tests.csproj -v minimal --filter FullyQualifiedName~EmulatorRunnerTests -p:AndroidToolsDisableMultiTargeting=false -p:DotNetTargetFrameworkVersion=10.0 — all 25 passed.

Live emulator startup and multiple-device scenarios were not rerun; the runner behavior is unchanged.

Keep device boot checks in outer builds and skip publish-only RID inner builds, matching the ABI query condition. Add three target-order regression cases.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 28, 2026 18:26

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

No active review issues are reported for the change that skips redundant device boot checks in publish-only RID inner builds.

No open issues 🎉

What changed in this PR

This PR avoids redundant device boot checks in .NET for Android publish-only runtime identifier (RID) inner builds while preserving outer-build device preparation.

Changes:

  • Skip _EnsureDeviceBooted when _ComputeFilesToPublishForRuntimeIdentifiers is true.
  • Preserve the outer-build ABI hook and explicit deployment/run-argument dependencies.
  • Add three regression cases covering inner builds, outer builds with an explicit RID and ADB target, and empty device selection.
File Description
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildOrderTests.cs Adds regression coverage for device boot conditions and ordering before the ABI query.
src/​Xamarin.Android.Build.Tasks/​Microsoft.Android.Sdk/​targets/​Microsoft.Android.Sdk.Application.targets Adds and documents the publish-only RID inner-build guard.

Review effort: Balanced

@jonathanpeppers
jonathanpeppers merged commit dc2dd52 into main Oct 28, 2026
42 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-repeated-device-checks branch October 28, 2026 21:51
jonathanpeppers added a commit that referenced this pull request Nov 23, 2026
…uilds (#13304) (#13731)

Backport of #13304.

Skip the `_EnsureDeviceBooted` target when
`$(_ComputeFilesToPublishForRuntimeIdentifiers)` is `true`, so
publish-only RID inner builds do not repeat the outer build's device
boot check. Add the `DeviceBootIsLimitedToOuterBuilds` regression test.

Conflict resolution: `BuildOrderTests.cs` on main contains other tests
that are not on this branch. Only the new test and its `using` lines
were kept.

(cherry picked from commit dc2dd52)

Co-authored-by: Copilot App <[email protected]>
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.

3 participants