Repository navigation
[release/11.0.1xx] [Xamarin.Android.Build.Tasks] Support MT in four transform tasks - #13730
jonathanpeppers merged 3 commits into
Conversation
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]>
There was a problem hiding this comment.
🔵 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
MultithreadedAndroidTaskbase. - 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
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
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) ontoMultithreadedAndroidTaskwith[MSBuildMultiThreadableTask]. - #13733 (
23cc1014) has since landed inrelease/11.0.1xx. It deletes that file and replaces the task with item operations inMicrosoft.Android.Sdk.AssemblyResolution.targetsandMicrosoft.Android.Sdk.Aot.targets, matching #13287 on main. - GitHub reports the PR as
CONFLICTING. The green checks at this head ran against8e578c4, not the current tip7414c55.
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,UnhandledExceptionLoggerand 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.
UnhandledExceptionLoggerresolves paths throughTaskEnvironment.GetAbsolutePath. Callers that pass null keep the old behavior.- The analyzer only checks multithreaded tasks. It is private and analyzers-only, and the
dotnet-toolsfeed matches upstream.
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]>
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
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.Xml10.0.15,K4os.Compression.LZ41.1.11) and the analyzer version and reference lines. - MSBuild 18.9.6 needs
System.Security.Cryptography.Xml10.0.10, below the 10.0.15 pin, so there's no downgrade. The analyzer reference isPrivateAssets=allandIncludeAssets=analyzers, so it doesn't flow into the packs, and noMicrosoft.Build*.dllships. TaskEnvironment.Fallbackneeds MSBuild 18.6 or later, and the 11.0.1xx SDK requires 18.11 or later, so no supported host lacks these APIs.AppendCustomMetadataToItemGroupandRuntimeIdentifierToAbiare 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.MultiThreadedMigrationTestshas 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 touchesNuGet.configlines 7–8, separate from thedotnet-toolsline.
Non-blocking:
- The title still says "four"; it should say "two".
- MSBuild+Emulator 8 failed during checkout (
git submodule updateexit 128), before any tests ran. Most MSBuild test lanes, including the one that runsMultiThreadedMigrationTests, are still running.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
ce488b2c9e9fc61d56e8783ade17412d4024116a↓ The Xamarin task build stopped before compilation because
xa-prep-tasks.dllis missing; full CI has not been inspected.Backport of #13243.
Allow the two remaining transform tasks in
release/11.0.1xx(AppendCustomMetadataToItemGroupandRuntimeIdentifierToAbi) to run in-process in multithreaded MSBuild instead of using separate task hosts. Bring overMultithreadedAndroidTask, project-relative exception logging, the analyzer rules, documentation, and tests.Conflict resolutions
MSBuildReferences.projitems: bump MSBuild from 18.7.1 to 18.9.6 and addMicrosoft.Build.TaskAuthoring.Analyzer. KeepSystem.Security.Cryptography.Xmlat 10.0.15 and retainK4os.Compression.LZ41.1.11.Microsoft.Android.Build.Tasks.csproj: add only the analyzer reference. The release branch already referencesSystem.IO.Hashingthrough project dependencies and keepsELFSharpin the Xamarin task project.SplitProperty.csdeleted because [release/11.0.1xx] [Xamarin.Android.Build.Tasks] Split ABI values in MSBuild #13689 replaced the task with XML.MultiThreadedMigrationTestsdiscovers tasks by scanning assembly metadata and does not nameSplitProperty; no test references to the deleted task were added.ProcessRuntimePackLibraryDirectories.csdeleted 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 becausexa-prep-tasks.dllwas 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.mdworkflow documentation, and in particular should include: