Skip to content

[Xamarin.Android.Build.Tasks] Support multithreaded resource paths - #13465

Merged
simonrozsival merged 1 commit into
mainfrom
jonathanpeppers-mt-resource-path-computation
Nov 11, 2026
Merged

simonrozsival merged 1 commit into
mainfrom
jonathanpeppers-mt-resource-path-computation

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Run AndroidComputeResPaths in-process with -mt. Resolve physical paths through TaskEnvironment, preserving logical names and original items. Update MSBuild references to 18.12.3-1.26559.117 for public GetCanonicalForm support.

Windows validation: local SDK build passed; 14 resource checks and 158 shared task tests passed. Ordinary and strict MT builds passed, including task execution on stable MSBuild 18.12.2. Both resource-task calls ran without TaskHost.

Test commands
  • .\bin\Release\dotnet\dotnet.exe test bin\TestRelease\net11.0\Xamarin.Android.Build.Tests.dll --filter 'FullyQualifiedName~AndroidComputeResPathsTests|FullyQualifiedName~MultiThreadedMigrationTests.MigratedTasksHaveDirectAttribute' --logger 'trx;LogFileName=msbuild-18.12-resource-paths.trx' --results-directory bin\BuildRelease\simplify-results — 14 passed.
  • .\bin\Release\dotnet\dotnet.exe test tests\Microsoft.Android.Build.BaseTasks-Tests\Microsoft.Android.Build.BaseTasks-Tests.csproj -c Release -nr:false --logger 'trx;LogFileName=msbuild-18.12-base-tasks.trx' --results-directory bin\BuildRelease\simplify-results — 158 passed.

Resolve physical resource paths through TaskEnvironment so the task
can run in-process with -mt.  Preserve logical names and original items.

Update MSBuild references to 18.12 for public GetCanonicalForm support.

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

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

There are no active review issues blocking the resource-path multithreading changes.

No open issues 🎉

What changed in this PR

Enables AndroidComputeResPaths to run in-process under MSBuild multithreaded execution, resolving physical paths through TaskEnvironment while preserving logical names and original resource items.

Changes:

  • Migrates the resource-path task to the multithreaded base class and project-scoped path resolution.
  • Adds ordinary and strict multithreaded build tests, plus relative asset-pack and missing-resource coverage.
  • Updates MSBuild references for public GetCanonicalForm support and documents path-handling guidance.
File Description
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​AndroidComputeResPathsTests.cs Adds path-resolution coverage and removes working-directory mutation from existing tests.
src/​Xamarin.Android.Build.Tasks/​Tasks/​AndroidComputeResPaths.cs Enables multithreaded execution and resolves physical paths through TaskEnvironment.
src/​Microsoft.Android.Build.BaseTasks/​MSBuildReferences.projitems Updates MSBuild references to 18.12.3-1.26559.117.
Documentation/​guides/​MSBuildBestPractices.md Updates the documented MSBuild reference version.
.github/​copilot-instructions.md Adds guidance on public API verification and path canonicalization.

Review effort: Balanced

@simonrozsival
simonrozsival enabled auto-merge (squash) November 11, 2026 08:43
@simonrozsival
simonrozsival merged commit aa91d32 into main Nov 11, 2026
41 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers-mt-resource-path-computation branch November 11, 2026 09:46
jonathanpeppers added a commit that referenced this pull request Nov 17, 2026
Update System.Security.Cryptography.Xml to 10.0.15, which also updates its Pkcs dependency to 10.0.15.

Use MSBuild 18.12.2 from nuget.org instead of the dotnet-tools prerelease. Its reference assemblies expose AbsolutePath.GetCanonicalForm, which #13465 needed.

Validation on Windows:

  * build.cmd: passed
  * dotnet test tests/Microsoft.Android.Build.BaseTasks-Tests/Microsoft.Android.Build.BaseTasks-Tests.csproj: 162 passed, 8 skipped
  * dotnet-local.cmd test bin/TestDebug/net11.0/Xamarin.Android.Build.Tests.dll --filter Name~AndroidComputeResPaths: 13 passed

Co-authored-by: Copilot App <[email protected]>
jonathanpeppers pushed a commit that referenced this pull request Nov 24, 2026
…3756)

Context: #13465
Context: #13480
Context: #13504
Context: #13512
Context: #13615

`.github/skills/code-review/references/msbuild-rules.md` (loaded by `.github/workflows/android-reviewer.md` during automated pull request reviews) still instructed reviewers to prefer `AndroidTask` and `AsyncTask` for MSBuild tasks. That contradicts `.github/copilot-instructions.md` and `Documentation/guides/MSBuildBestPractices.md` after `#13465` and `#13504`, where new and migrated tasks must use `MultithreadedAndroidTask` or `MultithreadedAndroidToolTask` and declare `[MSBuildMultiThreadableTask]` directly on each concrete class because `AndroidTask`, `AsyncTask`, and `AndroidToolTask` capture the process working directory in their constructors.

An audit of recent inline review comments surfaced four multithreaded-task review gaps in these rules:

  * Task base classes and path canonicalization: flag new tasks on `AndroidTask`, `AsyncTask`, or `AndroidToolTask`, and flag `[MSBuildMultiThreadableTask]` added to tasks still inheriting those bases (`#13615`), while allowing unmigrated legacy tasks to keep their base until all code paths are thread-safe. Document `TaskEnvironment.GetAbsolutePath(path).GetCanonicalForm()` for collapsing `.`/`..` segments rather than `Path.GetFullPath(TaskEnvironment.GetAbsolutePath(...))`, which fails `MSBuildTask0002` in this repository (`#13480`).
  * Background logging and `TaskEnvironment` thread safety: migrating an `AsyncTask` to `MultithreadedAndroidTask` switches `CreateTaskLogger()` from the queued `AsyncTask` overload to `MSBuildExtensions.CreateTaskLogger(this Task)`, which calls `task.Log.*` directly on background threads (`#13512`). Document keeping background logging marshaled to the executing thread, preserving `Yield()`/`Reacquire()` in `try`/`finally`, and resolving `TaskEnvironment` paths/settings before `Task.WhenAll` fan-out (`#13615`).
  * `RegisterTaskObject` cache keys under `-mt`: `RegisteredTaskObjectLifetime.Build` entries are shared across concurrent inner builds of the same project (such as different RIDs or TFMs), and `MultithreadedAndroidTask` omits `ProjectSpecificTaskObjectKey` (`#13480`). Require a configuration-specific discriminator such as the resolved absolute intermediate output directory, with matching key type, value, and lifetime across producer and consumer.

Validation: Markdown-only review skill update under `.github/skills/`; no SDK build or test execution required per `.github/skills/tests/SKILL.md`. Verified all referenced task types, methods, and analyzer settings against `src/Microsoft.Android.Build.BaseTasks/` and `.editorconfig`.

Co-authored-by: PureWeen <[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