Skip to content

[Xamarin.Android.Build.Tasks] Move simple task logic to targets - #13287

Merged
jonathanpeppers merged 1 commit into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-task-logic-in-targets
Oct 28, 2026
Merged

jonathanpeppers merged 1 commit into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-task-logic-in-targets

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

MSBuild -mt is the motivation for this change. Tasks without multithreaded execution support run in external task hosts, even when their work is only a condition or an item check. Express that work in targets instead of maintaining custom tasks for it.

Replace CheckProjectItems and LogWarningsForFiles with the existing AndroidError and AndroidWarning tasks, adding file association support to both. XA0100 still reports each offending file and stops downstream build work on the final error. XA0101 keeps its text, file association, exclusions, suppression, and warning-as-error behavior, and now uses a localizable resource.

Replace ProcessRuntimePackLibraryDirectories with target-local item filtering for the five system library stubs. Keep case-insensitive filename/package matching and require RID metadata. Remove the obsolete Mono package check; CoreCLR and NativeAOT remain. Keep the existing target hooks and remove the three unused task classes and registrations.

This is not a measured wall-time speedup claim. In representative .NET 11 C# incremental captures with two Content files, total scheduled tasks changed from 254 to 253 and task messages from 1662 to 1657. External task-host calls stayed at 31: two batched AndroidWarning calls replace one warning-wrapper call and the empty project-check call. The removed runtime filter already ran in-process.

Validation

Used a locally built Release Android SDK with .NET SDK 11.0.100-rc.2.26504.105, framework/reference/runtime 11.0.0-rc.2.26504.105, ILLink 11, and MonoTargets 11. Verified managed/native APK runtime hashes. Temporary version overrides were removed from the diff. Tests use JDK 21 and the local Android SDK/NDK.

  • call .\dotnet-local.cmd build Microsoft.Android.slnx -t:BuildDotNet -c Release -nr:false -v:minimal -bl:remove-mono-sdk.binlog after VS 18 Insiders VsDevCmd.bat: passed, 207 existing warnings, 0 errors.
  • .\dotnet-local.cmd build src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\Xamarin.Android.Build.Tests.csproj -c Release --no-restore -nr:false -v:quiet: passed after the final test cleanup, 0 errors.
  • .\dotnet-local.cmd test bin\TestRelease\net10.0\Xamarin.Android.Build.Tests.dll --filter "Name~EmbeddedLibraries|Name~ContentWarnings|Name~RuntimeLibraryFiltering|Name~CheckContentBuildAction|Name~ContentBuildActionForRazor|Name~NonAndroidNativeLibrariesDoNotProduceWarnings": passed, 12 cases before removing the duplicate valid-library case.
  • .\dotnet-local.cmd test bin\TestRelease\net10.0\Xamarin.Android.Build.Tests.dll --filter "Name~EmbeddedLibraries": passed, both remaining cases after that removal.
  • .\dotnet-local.cmd build <probe>\TargetLogicProbe.csproj -c Debug --no-restore -m -nr:false -v:minimal -bl:modified-ordinary.binlog: passed with two expected XA0101 warnings.
  • .\dotnet-local.cmd build <probe>\TargetLogicProbe.csproj -c Debug --no-restore -m -mt -nr:false -warnaserror:MSB4286,MSB4287,MSB4288 -v:minimal -bl:modified-mt.binlog: passed with two expected XA0101 warnings. Inspected saved binlogs with binlogtool.

Source issue: N/A.


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

MSBuild -mt runs tasks without thread support in external task hosts.
Express simple checks and item filtering in targets instead of keeping
custom tasks for this work.

Use AndroidError and AndroidWarning with file associations for XA0100
and XA0101.  Report all invalid libraries, then stop downstream targets
on the final error.  Filter runtime library stubs with MSBuild items
and remove the legacy Mono package check.

Add focused project-build tests beside the related existing tests.

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

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

Customer-facing target batching and runtime-packaging changes warrant human confirmation of the reported validation before approval.

No open issues 🎉

1 file not reviewed
  • src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
What changed in this PR

Moves simple .NET for Android build checks and runtime-library filtering from custom tasks into MSBuild targets, reducing task overhead in multithreaded builds without claiming a measured build-time improvement.

Changes:

  • Reuses AndroidError and AndroidWarning for file-associated diagnostics and makes XA0101 localizable.
  • Replaces runtime-pack filtering with target-local items and removes three obsolete tasks.
  • Adds regression coverage for diagnostics, downstream build stopping, and runtime-library filtering.
File Description
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Common.targets Replaces project-check and content-warning tasks with target logic.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​InvalidConfigTests.cs Tests embedded-library errors and downstream build stopping.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildWithLibraryTests.cs Tests content-warning suppression and warning-as-error behavior.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildTest2.cs Tests runtime stub filtering and retained libraries.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ProcessRuntimePackLibraryDirectories.cs Removes the replaced runtime-filtering task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​LogWarningsForFiles.cs Removes the replaced warning-wrapper task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​CheckProjectItems.cs Removes the replaced project-validation task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​AndroidWarning.cs Adds diagnostic file association.
src/​Xamarin.Android.Build.Tasks/​Tasks/​AndroidError.cs Adds diagnostic file association.
src/​Xamarin.Android.Build.Tasks/​Properties/​Resources.resx Adds the localizable XA0101 message.
src/​Xamarin.Android.Build.Tasks/​Properties/​Resources.Designer.cs Adds the XA0101 resource accessor.
src/​Xamarin.Android.Build.Tasks/​Microsoft.Android.Sdk/​targets/​Microsoft.Android.Sdk.AssemblyResolution.targets Filters system library stubs using target-local items.
Documentation/​docs-mobile/​messages/​index.md Removes obsolete task-prefix entries.

Review effort: Balanced

@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Oct 28, 2026
@jonathanpeppers

Copy link
Copy Markdown
Member Author

/review

@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Android PR Reviewer has started processing this issue comment

@jonathanpeppers

Copy link
Copy Markdown
Member Author

The automated reviewer run did not produce a usable review: https://github.com/dotnet/android/actions/runs/40700757014/job/122862037169

The saved agent transcript shows that it loaded the code-review skill and searched for the GitHub PR-reading tool, then ended without reading the diff or recording findings. The review-output file is empty.

The conclusion job failed with missing_terminal_safe_output: the agent exited with code 0 but supplied no review result. The API logs also contain two earlier HTTP 401 errors: "You do not have access to the organization tied to the API key." The logs do not establish why the agent later stopped.

This was a reviewer-run failure, not a completed review with no findings.

@dalexsoto

Copy link
Copy Markdown
Member

@jonathanpeppers Not reviewing this request in this iteration: The read-only review worker stopped with an authorization error: "401 You do not have access to the organization tied to the API key." It did not produce a complete review. GitHub access is working, and the request and partial source evidence are preserved; I am withholding a formal decision rather than treating the failed attempt as a clean review.

@jonathanpeppers
jonathanpeppers merged commit d48225b into dotnet:main Oct 28, 2026
41 checks passed
jonathanpeppers added a commit that referenced this pull request Nov 23, 2026
Replace three custom tasks with MSBuild item operations and file-aware
XA0100 and XA0101 diagnostics. Preserve the release branch's Mono AOT
and runtime-pack library directory discovery for native linking.

(cherry picked from commit d48225b)

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

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.

4 participants