Skip to content

[release/11.0.1xx] [Xamarin.Android.Build.Tasks] Support MT in four transform tasks - #13730

Merged
jonathanpeppers merged 3 commits into
release/11.0.1xxfrom
jonathanpeppers-backport-mt-infrastructure
Nov 24, 2026
Merged

jonathanpeppers merged 3 commits into
release/11.0.1xxfrom
jonathanpeppers-backport-mt-infrastructure

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: ce488b2c9e9fc61d56e8783ade17412d4024116a

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ The resolved targets match the release branch; two focused builds and seven tests passed.
↓ The Xamarin task build stopped before compilation because xa-prep-tasks.dll is missing; full CI has not been inspected.

Backport of #13243.

Allow the two remaining transform tasks in release/11.0.1xx (AppendCustomMetadataToItemGroup and RuntimeIdentifierToAbi) to run in-process in multithreaded MSBuild instead of using separate task hosts. Bring over MultithreadedAndroidTask, project-relative exception logging, the analyzer rules, documentation, and tests.

Conflict resolutions

  1. MSBuildReferences.projitems: bump MSBuild from 18.7.1 to 18.9.6 and add Microsoft.Build.TaskAuthoring.Analyzer. Keep System.Security.Cryptography.Xml at 10.0.15 and retain K4os.Compression.LZ4 1.1.11.
  2. Microsoft.Android.Build.Tasks.csproj: add only the analyzer reference. The release branch already references System.IO.Hashing through project dependencies and keeps ELFSharp in the Xamarin task project.
  3. Keep SplitProperty.cs deleted because [release/11.0.1xx] [Xamarin.Android.Build.Tasks] Split ABI values in MSBuild #13689 replaced the task with XML. MultiThreadedMigrationTests discovers tasks by scanning assembly metadata and does not name SplitProperty; no test references to the deleted task were added.
  4. Keep ProcessRuntimePackLibraryDirectories.cs deleted because [release/11.0.1xx] [Xamarin.Android.Build.Tasks] Move simple task logic to targets #13733 replaced the task with MSBuild item operations. The replacement AOT and assembly resolution targets match the release branch.

Validation

  • git diff --check origin/release/11.0.1xx...HEAD — passed.
  • dotnet build src\Microsoft.Android.Build.BaseTasks\Microsoft.Android.Build.BaseTasks.csproj --no-restore --verbosity quiet — passed; 0 warnings, 0 errors.
  • dotnet build src\Microsoft.Android.Build.Tasks\Microsoft.Android.Build.Tasks.csproj --no-restore --verbosity quiet — passed; 0 warnings, 0 errors.
  • dotnet build src\Xamarin.Android.Build.Tasks\Xamarin.Android.Build.Tasks.csproj --no-restore --no-dependencies -p:BuildProjectReferences=false --verbosity quiet — stopped before compilation with MSB4062 because xa-prep-tasks.dll was not present. No Prepare or SDK build was run.
  • dotnet test tests\Microsoft.Android.Build.BaseTasks-Tests\Microsoft.Android.Build.BaseTasks-Tests.csproj --no-restore --filter MultithreadedAndroidTask --verbosity minimal — 7 passed, 0 failed, 0 skipped.

Full validation, including the Xamarin task build and migration test, runs in CI.


Pull Request
title and
description
should follow the
commit-messages.md workflow documentation, and in particular should include:

  • Useful description of why the change is necessary.
  • Links to issues fixed
  • Unit tests

Allow AppendCustomMetadataToItemGroup, RuntimeIdentifierToAbi, and ProcessRuntimePackLibraryDirectories to run in-process in multithreaded MSBuild. Keep the release branch XML replacement for SplitProperty from #13689.

Bring over the MT task base and exception path handling, MSBuild 18.9.6, task authoring analyzer, documentation, and tests. Preserve the release branch dependency versions and references.

(cherry picked from commit 4ffbe4d)

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 16:24

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

Validation did not compile Xamarin.Android.Build.Tasks or run its migration test, so the task-isolation and shared MSBuild dependency changes still need full CI and ordinary/strict MT build confirmation on the release branch.

No open issues 🎉

What changed in this PR

Backports #13243 to release/11.0.1xx to reduce task-host overhead in multithreaded MSBuild. It covers the three remaining transform tasks; SplitProperty stays deleted following #13689.

Changes:

  • Enable three transform tasks to run in-process using the new MultithreadedAndroidTask base.
  • Preserve coded exception and file-lock diagnostics with project-relative path resolution.
  • Update MSBuild dependencies and add analyzer enforcement, migration guidance, and regression tests.
File Description
tests/​Microsoft.Android.Build.BaseTasks-Tests/​MultithreadedAndroidTaskTests.cs Test execution results, exception codes, and file-lock diagnostics.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​MultiThreadedMigrationTests.cs Validate task attributes and base classes through assembly metadata.
src/​Xamarin.Android.Build.Tasks/​Tasks/​RuntimeIdentifierToAbi.cs Enable in-process multithreaded RID conversion.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ProcessRuntimePackLibraryDirectories.cs Enable in-process multithreaded runtime-pack processing.
src/​Xamarin.Android.Build.Tasks/​Tasks/​AppendCustomMetadataToItemGroup.cs Enable in-process multithreaded metadata transformation.
src/​Microsoft.Android.Build.Tasks/​Microsoft.Android.Build.Tasks.csproj Add the private task-authoring analyzer reference.
src/​Microsoft.Android.Build.BaseTasks/​UnhandledExceptionLogger.cs Resolve diagnostic paths using the task environment.
src/​Microsoft.Android.Build.BaseTasks/​MultithreadedAndroidTask.cs Add a task base that avoids capturing the process working directory.
src/​Microsoft.Android.Build.BaseTasks/​MSBuildReferences.projitems Update shared MSBuild references and add the analyzer.
NuGet.config Add the package feed for the analyzer dependency.
Documentation/​guides/​MSBuildBestPractices.md Document safe task migration and validation.
Directory.Build.props Define the shared analyzer version.
.github/​copilot-instructions.md Require multithreaded support for new tasks.
.editorconfig Enforce selected task-safety analyzer rules as errors.

Review effort: Balanced

@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) November 23, 2026 21:22
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 23, 2026

@dalexsoto dalexsoto 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.

Reviewed dde46f2 statically against release/11.0.1xx; I didn't build or run anything. The backported code looks right, but the PR no longer merges into the current release branch.

Blocker: modify/delete conflict on ProcessRuntimePackLibraryDirectories.cs

  • This PR moves src/Xamarin.Android.Build.Tasks/Tasks/ProcessRuntimePackLibraryDirectories.cs (L12-13) onto MultithreadedAndroidTask with [MSBuildMultiThreadableTask].
  • #13733 (23cc1014) has since landed in release/11.0.1xx. It deletes that file and replaces the task with item operations in Microsoft.Android.Sdk.AssemblyResolution.targets and Microsoft.Android.Sdk.Aot.targets, matching #13287 on main.
  • GitHub reports the PR as CONFLICTING. The green checks at this head ran against 8e578c4, not the current tip 7414c55.

Fix: rebase, keep the deletion and drop this hunk. Don't re-add the file: it would have no UsingTask and be dead code. The PR then migrates two tasks (AppendCustomMetadataToItemGroup and RuntimeIdentifierToAbi), so please update the title ("four") and description ("three"). MultiThreadedMigrationTests finds tasks by base type, so it needs no change.

Everything else checks out against upstream #13243:

  • .editorconfig, the docs, MultithreadedAndroidTask, UnhandledExceptionLogger and both test files are identical to upstream.
  • The three described conflict resolutions are correct.
  • Both remaining tasks are pure string/item transforms with no file system, environment, current-directory or mutable static state, so running them in-process is safe.
  • UnhandledExceptionLogger resolves paths through TaskEnvironment.GetAbsolutePath. Callers that pass null keep the old behavior.
  • The analyzer only checks multithreaded tasks. It is private and analyzers-only, and the dotnet-tools feed matches upstream.

jonathanpeppers and others added 2 commits November 24, 2026 08:45
Keep ProcessRuntimePackLibraryDirectories deleted because the release branch replaced it with MSBuild item operations.

Co-authored-by: Copilot App <[email protected]>
Include the latest release-branch changes before updating the backport pull request.

Co-authored-by: Copilot App <[email protected]>
@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto 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.

Re-reviewed ce488b2 statically against release/11.0.1xx (bdbe0a6); I didn't build or run anything. My earlier blocker is fixed, so I'm approving.

Previous blocker: fixed. The merges kept ProcessRuntimePackLibraryDirectories.cs deleted; it's absent at this head and at the release tip. Nothing under Xamarin.Android.Build.Tasks still has a UsingTask for it or for SplitProperty, and its .targets files match the release branch. The description now says two tasks.

What I checked:

  • All 13 files against upstream #13243 (4ffbe4d). Eight are identical. The rest differ only by the release pins described in the PR (MSBuild 18.9.6, System.Security.Cryptography.Xml 10.0.15, K4os.Compression.LZ4 1.1.11) and the analyzer version and reference lines.
  • MSBuild 18.9.6 needs System.Security.Cryptography.Xml 10.0.10, below the 10.0.15 pin, so there's no downgrade. The analyzer reference is PrivateAssets=all and IncludeAssets=analyzers, so it doesn't flow into the packs, and no Microsoft.Build*.dll ships.
  • TaskEnvironment.Fallback needs MSBuild 18.6 or later, and the 11.0.1xx SDK requires 18.11 or later, so no supported host lacks these APIs.
  • AppendCustomMetadataToItemGroup and RuntimeIdentifierToAbi are still pure item/string transforms with no shared state. They're the only types with the multithreaded markers, so the analyzer's error-level rules don't affect release-only code.
  • MultiThreadedMigrationTests has no allowlist, and all five assemblies it reads are always in the pack, so it should find the two migrated tasks on this branch.
  • The one release commit not in this PR (bdbe0a6, #13571) only touches NuGet.config lines 7–8, separate from the dotnet-tools line.

Non-blocking:

  • The title still says "four"; it should say "two".
  • MSBuild+Emulator 8 failed during checkout (git submodule update exit 128), before any tests ran. Most MSBuild test lanes, including the one that runs MultiThreadedMigrationTests, are still running.

@jonathanpeppers
jonathanpeppers merged commit 9c5f7f7 into release/11.0.1xx Nov 24, 2026
44 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-backport-mt-infrastructure branch November 24, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants