Repository navigation
[Build.Tasks] Emit resource designers with System.Reflection.Metadata - #13150
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Framework-hosted MSBuild lacks required runtime dispatch, and the regeneration test holds a file handle that blocks replacement on Windows.
2 open findings
What changed in this PR
Replaces Cecil-based resource designer generation with System.Reflection.Metadata to reduce task execution time and allocations in .NET for Android builds.
Changes:
- Introduces the metadata emitter for normal and design-time builds.
- Moves regression tests and adds a benchmark harness.
- Removes obsolete signing helpers and updates third-party notices.
| File | Description |
|---|---|
| THIRD-PARTY-NOTICES.TXT | Removes StrongNameSigner notice. |
| tests/Microsoft.Android.ResourceDesigner.Benchmarks/ResourceDesignerBenchmarks.cs | Adds generation benchmarks and output checks. |
| tests/Microsoft.Android.ResourceDesigner.Benchmarks/README.md | Documents measurements and validation. |
| tests/Microsoft.Android.ResourceDesigner.Benchmarks/Program.cs | Adds benchmark and verification entry points. |
| tests/Microsoft.Android.ResourceDesigner.Benchmarks/Microsoft.Android.ResourceDesigner.Benchmarks.csproj | Configures benchmark dependencies and inputs. |
| tests/Microsoft.Android.ResourceDesigner.Benchmarks/BenchmarkBuildEngine.cs | Supplies benchmark task hosting. |
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | Switches normal-build task registration. |
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj | Removes obsolete signing source references. |
| src/Xamarin.Android.Build.Tasks/Utilities/RtxtParser.cs | Makes formatting culture explicit. |
| src/Xamarin.Android.Build.Tasks/Utilities/ResourceParser.cs | Cleans imports and specifies formatting culture. |
| src/Xamarin.Android.Build.Tasks/Utilities/ResourceIdentifier.cs | Cleans imports and specifies formatting culture. |
| src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.ResourceMap.cs | Extracts shared map loading. |
| src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs | Removes relocated map-loading implementation. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/AndroidResourceTests.cs | Removes migrated determinism tests. |
| src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs | Removes Cecil-based task. |
| src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Resource.Designer.targets | Switches design-time task registration. |
| src/Microsoft.Android.Build.Tasks/Utilities/ResourceDesignerAssemblyEmitter.cs | Implements metadata and IL emission. |
| src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj | Embeds resource test input. |
| src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/GenerateResourceDesignerAssemblyTests.cs | Tests output contracts, determinism, and registrations. |
| src/Microsoft.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs | Adds metadata-backed generation task. |
| src/Microsoft.Android.Build.Tasks/Resources/Resource.Designer.snk | Supplies designer identity key. |
| src/Microsoft.Android.Build.Tasks/Microsoft.Android.Build.Tasks.csproj | Includes key and shared parsing helpers. |
| src-ThirdParty/StrongNameSigner/SigningHelper.cs | Removes unused signing helper. |
| src-ThirdParty/Mono.Security.Cryptography/CryptoConvert.cs | Removes unused cryptographic conversion code. |
| .github/skills/update-tpn/SKILL.md | Updates vendored dependency inventory. |
🧠 Review effort: Balanced
40225cb to
cd59cd8
Compare
cd59cd8 to
b53e6da
Compare
b53e6da to
16f8413
Compare
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
⚠️ Needs Changes
Findings: 0 errors, 1 warning, 0 suggestions. The new task retains the legacy working-directory-dependent base rather than supporting multithreaded MSBuild execution; the inline comment identifies the required task/environment migration and validation.
The metadata emitter otherwise appears to preserve the designer contract: historical assembly identity without signing, application properties/constants, library reference-assembly metadata, array allocation/initialization behavior, deterministic output, and copy-if-changed semantics. The expanded tests cover these contracts, a real resource set, remapping, and both task-registration surfaces. The previously reported Windows file-sharing and runtime-selection concerns are addressed in the current source.
CI: GitHub reports all 41 checks successful, including the aggregate dotnet-android check for Azure build 1653244. Direct Azure build/timeline confirmation was unavailable because both az devops invoke queries required authentication; I did not independently verify Azure test details.
Local validation: Attempted dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj --no-restore -v minimal --filter FullyQualifiedName~GenerateResourceDesignerAssemblyTests, but the CLI failed during first-use initialization before running tests. This environment also has no .NET 11 SDK installed. No source changes were made.
Generated by Android PR Reviewer for #13150 · copilot · gpt61 · 53.4 AIC · ⌖ 7.49 AIC · ⊞ 19.3K
Comment /review to run again
Context: #13150 (comment) Emit the project target-framework moniker and matching System.Runtime reference instead of preserving the old netstandard2.1 baseline. Keep the historical designer assembly identity so existing binary libraries continue to compile. Remove the R.txt-only timestamp shortcut: retargeting the same output must update its framework metadata even when resources are unchanged. Content comparison still preserves identical deterministic outputs. Cover application and library framework metadata for .NET 10, 11, and 12, regeneration after retargeting, and the normal/design-time target wiring. Co-authored-by: Copilot App <[email protected]>
Context: #13150 (comment) Emit the project target-framework moniker and matching System.Runtime reference instead of preserving the old netstandard2.1 baseline. Keep the historical designer assembly identity so existing binary libraries continue to compile. Remove the R.txt-only timestamp shortcut: retargeting the same output must update its framework metadata even when resources are unchanged. Content comparison still preserves identical deterministic outputs. Cover application and library framework metadata for .NET 10, 11, and 12, regeneration after retargeting, and the normal/design-time target wiring. Co-authored-by: Copilot App <[email protected]>
1766feb to
f0dcc13
Compare
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
Reviewed all 19 changed files, the previous emitter, relevant callers and task registrations, and reconciled the implementation with the PR description and resolved review threads. The replacement preserves the designer's assembly identity, application/library shape, array semantics, and deterministic-output handling. The directly declared multithreading attribute, project-scoped paths/retry settings, and normal/design-time metadata assertions are good coverage for this migration. I did not independently reproduce the recorded performance measurements.
CI: At review time, 39 of 41 GitHub checks succeeded, with no reported failures; macOS MSBuild 5 was still running and the overall dotnet-android check remained queued for Azure build 1658536. The direct Azure build-status query required authentication unavailable to this workflow, so CI is not confirmed green.
Local validation: Attempted dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj --no-restore -v minimal --filter FullyQualifiedName~GenerateResourceDesignerAssemblyTests; the runner failed during .NET first-run initialization (NuGet-Migrations mutex creation), before building or executing tests. No local test pass is claimed.
Generated by Android PR Reviewer for #13150 · copilot · gpt61 · 101.1 AIC · ⌖ 8.49 AIC · ⊞ 19.5K
Comment /review to run again
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
One blocking issue remains in the project-framework metadata migration:
Design-time retargeting can keep the previous framework’s designer — Xamarin.Android.Resource.Designer.targets:159–179.
The shipped _GenerateResourceDesignerAssembly target still declares only R.txt as its incremental input. If retargeting reuses the designer output location and the unchanged R.txt is older than the existing DLL, MSBuild skips the target entirely. The task’s removed timestamp shortcut does not help because Execute() is never called. The designer consequently retains the old TargetFrameworkAttribute and System.Runtime reference—for example, .NET 12 metadata after retargeting that output to .NET 11. Property-change cleanup in Xamarin.Android.Common.targets:601–609 excludes design-time builds, and unchanged R.txt generation preserves its timestamp.
The existing target gate was harmless for this particular dependency with the old emitter’s fixed netstandard metadata; the new project-framework-dependent output makes it a regression. Following the project framework is the correct intended behavior, not something to revert. Make framework selection invalidate the shipped target, or remove that target’s timestamp gate and rely on deterministic copy-if-changed. Add a target-level retargeting case that keeps the output path fixed and R.txt older, asserting both framework metadata and the assembly reference; the direct Execute() and custom registration-target tests bypass this gate.
The prior host-dispatch, Windows stream-lifetime, multithreaded-task, and shared-map-helper findings are fixed or superseded. The separate final integration/completeness pass found no additional high-confidence blockers. This is a static source review; I did not run builds or tests.
Context: #13150 (review) The design-time target only tracked R.txt, so retargeting with an unchanged resource map could keep the previous framework metadata without calling GenerateResourceDesignerAssembly. Track the framework identifier and version in a write-only-when-different input file before the target performs its incremental check. Write this input before normal resource generation too, so switching back to design-time builds can reuse the normal designer without unnecessary regeneration. Import the shipped targets in regression tests covering application and library upgrades, downgrades, and round trips with a fixed output path and unchanged older R.txt. Verify both TargetFrameworkAttribute and System.Runtime, and preserve target skipping, bytes, and timestamps on no-op builds. Co-authored-by: Copilot App <[email protected]>
|
Addressed this review in c50b87f. The shipped target now tracks The regression tests import the actual shipped targets and cover application/library upgrades, downgrades, and round trips with a fixed output path and unchanged older Local validation:
|
dalexsoto
left a comment
There was a problem hiding this comment.
One blocking incremental-dependency issue remains.
Normal builds can retain the framework from an intervening design-time build. The new framework marker is written before _UpdateAndroidResgen, but only the design-time target consumes it as an incremental input: Xamarin.Android.Resource.Designer.targets, lines 159-180. Normal generation remains gated by Xamarin.Android.Common.targets, lines 1173-1187, whose inputs omit that marker.
With a fixed shared designer output location and otherwise unchanged inputs, a normal .NET 11 build -> .NET 12 design-time build -> original normal .NET 11 build can retain the .NET 12 designer. The design-time path deliberately reuses the normal DLL and now correctly regenerates it for .NET 12. Its properties cache is separate, however, so returning to the original normal framework leaves the normal cache and resource-generation flag current. Rewriting the marker back to .NET 11 does not invalidate normal resgen, and the emitter inside that skipped target never restores the designer. The result retains .NETCoreApp,Version=v12.0 and System.Runtime, Version=12.0.0.0 in the older-framework build.
Please make normal designer generation consume this dependency too, with ordering that also covers its preparation target's incremental decision, and add normal -> differently retargeted design-time -> original normal round-trip regressions for applications and libraries in both directions. Preserve the existing same-framework no-op/reuse assertions. The new tests invoke the design-time generation target only, so their design-time-only round trips do not exercise this normal-build return path.
The previous isolated design-time blocker is fixed. This finding concerns the replacement marker's normal-build integration, not the accepted project-framework metadata design: the exact-base emitter used fixed netstandard metadata, while the current fix newly enables property-only design-time retargeting of the reused normal DLL. The complete current changed-file/material-path review and separate final blocker pass found no additional high-confidence blockers.
Static source review only; no builds, tests, generators or CI were executed.
Context: #13150 (review) The design-time target only tracked R.txt, so retargeting with an unchanged resource map could keep the previous framework metadata without calling GenerateResourceDesignerAssembly. Track the framework identifier and version in a write-only-when-different input file before the target performs its incremental check. Write this input before normal resource generation too, so switching back to design-time builds can reuse the normal designer without unnecessary regeneration. Import the shipped targets in regression tests covering application and library upgrades, downgrades, and round trips with a fixed output path and unchanged older R.txt. Verify both TargetFrameworkAttribute and System.Runtime, and preserve target skipping, bytes, and timestamps on no-op builds. Co-authored-by: Copilot App <[email protected]>
498a53b to
2ea00b1
Compare
dalexsoto
left a comment
There was a problem hiding this comment.
The rebased revision preserves the accepted project-framework metadata contract and the previously fixed task-host, stream-lifetime and shared-helper integration. One carried-forward blocker remains; this is not a newly introduced finding from the rebase.
Normal generation still ignores the framework marker (src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Resource.Designer.targets:159-180; src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets:1137-1140,1171-1185,1232-1250).
The design-time path can reuse the normal designer DLL (designer targets:41-52). A normal framework-A build followed by a framework-B design-time build regenerates that shared DLL with framework-B metadata. Returning to framework A rewrites the framework marker, but neither normal preparation nor emission consumes it as an incremental input. With otherwise unchanged inputs, normal generation can skip and leave the framework-B designer, including a newer System.Runtime reference, for framework-A compilation. The separate design-time properties cache preserves an existing normal resgen flag (Xamarin.Android.DesignTime.targets:38-48), so it does not supply the missing invalidation. The exact-target emitter used fixed netstandard metadata; framework-dependent output makes this an attributable PR defect, not a reason to reject the accepted project-framework design.
Please make framework changes invalidate normal designer generation before both incremental decisions. Add application/library normal -> differently retargeted design-time -> original normal round trips in both directions, preserving same-framework no-op assertions. Current retargeting tests (GenerateResourceDesignerAssemblyTests.cs:207-248) exercise design-time-only round trips and miss the normal return.
Reviewed the complete current 19-file boundary and 37 changed/material paths against actual target/merge-base 510f36d8fc0ad797902ce65c9fdbe139899a8651, using identity-verified immutable reuse where applicable, the current discussion and accepted decisions, and a separate final independent-blocker pass. No additional high-confidence blocker remains. Static source review only; no builds, tests, generators or CI were executed.
Generate resource designer assemblies with System.Reflection.Metadata to avoid Cecil object graphs and framework assembly resolution. Keep the original task as the default and a head-to-head benchmark baseline. Share resource parsing and case maps, preserve deterministic output and resource values, and add an opt-in switch for normal and design-time builds. Add runtime/metadata checks and repeatable MAUI-input benchmarks. Local generation benchmarks show 2.56x faster library output and 2.95x faster application output, with 57-60% less managed allocation. These are task timings rather than end-to-end application build measurements. Validation: make all; 15 modern task/resource cases; 5 Cecil/parser cases; 8 Android application/library cases; 3 metadata design-time/incremental cases; Release benchmark verification and all 12 benchmark combinations. All passed. Exact commands and results are in the benchmark README. Co-authored-by: Copilot App <[email protected]>
The metadata emitter has been compared with the original implementation. Use it unconditionally for normal and design-time builds, removing the Cecil task and the private experiment switch. Move the existing signing key to the new task assembly and remove the now-unused StrongNameSigner and CryptoConvert sources and notice. Keep the recorded comparison results and a Cecil-free regression benchmark. Deterministic output coverage remains in the modern task test suite. Validation: make all and modern test project build pass without warnings; 15 task/resource cases and 11 parser, application/library, incremental, and design-time cases pass. Release benchmark build, verification, and all six metadata-only benchmark combinations pass. Co-authored-by: Copilot App <[email protected]>
Select the NET runtime at both resource designer task invocations so Framework-hosted MSBuild can dispatch the modern task correctly. Check the shipped invocation attribute in registration tests and add Windows MSBuild.exe cases using the existing Visual Studio locator. Dispose the PE reader and stream before regenerating changed output; otherwise replacing the open DLL causes a Windows sharing violation. Validation: make all and the modern test project build pass without warnings or errors. Fifteen task/resource tests and eleven integration cases pass. The two Windows-only MSBuild.exe cases are not run on macOS. The Release benchmark build and application/library verification pass. Co-authored-by: Copilot App <[email protected]>
Remove the development-only benchmark project, build engine, and README. The recorded performance comparison remains in the pull request body; keep the checked-in change focused on the emitter and regression tests. Validation: make all and the modern task test project build pass with no warnings or errors. Fifteen task/resource tests pass; the two Windows MSBuild.exe cases are skipped on macOS. No benchmark references remain. Co-authored-by: Copilot App <[email protected]>
Use invariant culture for scalar and array resource IDs, styleable indices, resource map keys, and parser diagnostics. Cover non-default cultures and custom negative signs in regression tests. Co-authored-by: Copilot App <[email protected]>
Link the existing resource designer key at its original location after rebasing onto #13110. Assert the exact historical public-key token for the metadata-generated designer. Co-authored-by: Copilot App <[email protected]>
Declare Runtime=NET on both resource designer registrations. Select TaskHostFactory only for Framework MSBuild and use the in-process registration under .NET MSBuild. Update registration coverage and remove the artificial negative-base exception-message assertion. Co-authored-by: Copilot App <[email protected]>
Main added direct legacy-task determinism coverage after this PR diverged. Keep all four application/library and determinism cases in the modern task suite, retaining the original test name and PE timestamp checks, and remove the duplicate that references the deleted task. Co-authored-by: Copilot App <[email protected]>
Context: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1650936 ApplicationPropertiesAndConstants and RealResourceSet load the generated DLL from disk, leaving Windows teardown dependent on asynchronous AssemblyLoadContext unloading. Load the image from memory and delete its backing file before the reflection assertions to verify the file is no longer locked. The Framework registration probes selected MSBuild 17.14 while the SDK requires MSBuild 18.7. Read the selected SDK minimumMSBuildVersion and explicitly skip Framework execution when the installed host cannot satisfy it or the MSBuild 18.0 NET TaskHost floor. Keep the Full/Core registration assertions ahead of platform and toolchain skips, and retain actual task execution on supported hosts. The designer suite passes in Debug and Release on macOS: 15 passed and two Windows-only execution cases skipped in each configuration. Co-authored-by: Copilot App <[email protected]>
Use MultithreadedAndroidTask and the directly declared MSBuildMultiThreadableTask attribute. Resolve designer input, case-map, and output paths with the engine-supplied TaskEnvironment, and keep parser helpers independent of process-relative file access. Add project-scoped file-copy retry settings without changing legacy callers. Move case-map parsing into MonoAndroidHelper.Basic without introducing MSBuild dependencies into its standalone consumers. Preserve the legacy netstandard2.1 designer contract independently of the consuming project TFM. Cover concurrent relative paths from separate project directories and both shipped registrations with ordinary and strict MT project graphs. Validation: make all passed. Designer tests passed in Debug and Release (18 passed, 2 Windows-only skipped each). Files/base MT tests passed (62 passed, 1 Windows-only skipped). Rebuilt-SDK resource and binary compatibility tests passed (8 passed, 2 unsupported NativeAOT Debug skipped); legacy parser/map tests passed (7 passed, 2 unsupported NativeAOT Debug skipped). Assembly-store tests passed for both TFMs (14 total). Local-SDK ordinary and strict -m -mt -nr:false -warnaserror:MSB4286,MSB4287,MSB4288 two-project probes passed; inspected binary log and project-specific remappings. Co-authored-by: Copilot App <[email protected]>
Context: #13150 (comment) Emit the project target-framework moniker and matching System.Runtime reference instead of preserving the old netstandard2.1 baseline. Keep the historical designer assembly identity so existing binary libraries continue to compile. Remove the R.txt-only timestamp shortcut: retargeting the same output must update its framework metadata even when resources are unchanged. Content comparison still preserves identical deterministic outputs. Cover application and library framework metadata for .NET 10, 11, and 12, regeneration after retargeting, and the normal/design-time target wiring. Co-authored-by: Copilot App <[email protected]>
Resource designers now reference the project framework, which can be newer than the test host. Resolve matching SDK or NuGet reference assemblies explicitly instead of depending on the dotnet installation found on PATH. Share the resolver between text and line inspection, keeping missing references fatal and dependency reads in memory. Exercise both inspection helpers in normal and design-time binary-library compatibility tests. Reproduce the CI failure without dotnet on PATH and validate all affected resource test families in that same environment. Co-authored-by: Copilot App <[email protected]>
Context: #13150 (review) The design-time target only tracked R.txt, so retargeting with an unchanged resource map could keep the previous framework metadata without calling GenerateResourceDesignerAssembly. Track the framework identifier and version in a write-only-when-different input file before the target performs its incremental check. Write this input before normal resource generation too, so switching back to design-time builds can reuse the normal designer without unnecessary regeneration. Import the shipped targets in regression tests covering application and library upgrades, downgrades, and round trips with a fixed output path and unchanged older R.txt. Verify both TargetFrameworkAttribute and System.Runtime, and preserve target skipping, bytes, and timestamps on no-op builds. Co-authored-by: Copilot App <[email protected]>
Context: #13410 Upstream removed tools/vswhere, but the Windows-only designer task-host test still needs Visual Studio MSBuild.exe to validate the Full MSBuild TaskHostFactory registration. Query vswhere.exe directly from the test instead of restoring the removed library. Co-authored-by: Copilot App <[email protected]>
…anges (#13150) Context: #13150 (review) Design-time builds can reuse the normal resource designer output. A normal framework-A build followed by a framework-B design-time build regenerated that shared designer for framework B, but returning to framework A skipped `_UpdateAndroidResgen` because its inputs did not include the framework marker. The normal build then compiled against the framework-B designer: an older framework kept stale metadata, and a newer one failed with CS1705 because the designer referenced a newer `System.Runtime`. Write the framework marker from a `_PrepareUpdateAndroidResgen` dependency and append it to `$(_UpdateAndroidResgenInputs)`, so both normal resgen incremental checks see framework changes. Same-framework builds still skip resource generation and preserve the designer. Add application and library normal -> retargeted design-time -> original normal round trips for older and newer design-time frameworks. All four cases failed before the target change and pass with it. Co-authored-by: Copilot App <[email protected]>
2ea00b1 to
f0c5aec
Compare
|
Addressed this review in f0c5aec. The framework marker is now produced by a New The rebase also needed one test-only follow-up: #13410 removed Local validation:
|
Context: #13410 vswhere is gone from the repository, and the only test needing it ran the designer registration under Visual Studio MSBuild.exe on Windows. Remove those two cases rather than reintroducing vswhere. The remaining cases still assert the Full (TaskHostFactory) and Core registrations statically, and run the registration under .NET MSBuild with and without -mt. Co-authored-by: Copilot App <[email protected]>


Context: #13110 preserves the resource designer's historical public-key identity without signing the generated assembly. #13144 fixes deterministic PE timestamps. Both changes are already merged; preserve their behavior when replacing the emitter.
Generating a resource designer with Mono.Cecil constructs an assembly object graph and resolves framework assemblies even though the output has a fixed, small metadata contract. For applications with large resource sets, this adds allocation and execution cost to resource generation.
Replace
Xamarin.Android.Tasks.GenerateResourceDesignerAssemblywith a .NET-only task inMicrosoft.Android.Build.Tasksthat writes metadata, IL, and the PE image directly withSystem.Reflection.Metadata. Use it for both normal and design-time builds, without an opt-in property or Cecil fallback. The emitter does not need Cecil or framework assembly resolution.Preserve the designer contract
Keep resource parsing and case mapping, application properties and constants, library reference-assembly metadata, array initialization, and copy-if-changed behavior. Preserve assembly version
1.0.0.0and public-key token1e9360d6629057eeso existing binary libraries continue to compile against the generated designer. Read the public key from the existing embeddedResource.Designer.snk; do not sign the generated assembly or move the key file.Generate
TargetFrameworkAttributefrom the project's$(TargetFrameworkIdentifier)and$(TargetFrameworkVersion), and scope framework type references to the matchingSystem.Runtimeversion instead of retaining the oldnetstandard2.1baseline. Remove the R.txt-only timestamp shortcut so retargeting the same output cannot retain stale framework metadata. Deterministic copy-if-changed still preserves unchanged output timestamps.Retain deterministic MVIDs and zero PE timestamps for deterministic builds, and fresh MVIDs and current PE timestamps otherwise. Consolidate all four application/library and determinism cases in the modern task test suite, retaining the coverage introduced by #13144.
Source-link the shared resource parsing utilities and consolidate line-oriented map parsing in
MonoAndroidHelper.Basic.cs, keeping that shared file free of MSBuild dependencies. Resolve R.txt, map, and output paths through the task'sTaskEnvironment; use the project-scoped copy/retry overload rather than cached process-wide environment settings. UseCultureInfo.InvariantCulturefor resource IDs, styleable indices, map keys, and parser diagnostics. Culture tests exercisear-SAandtr-TRwith a custom negative sign; remove the artificial negative-base exception-message assertion.Register the .NET task for both MSBuild hosts
Follow the existing conditional
<UsingTask/>pattern in both designer targets: declareRuntime="NET"for both hosts, selectTaskFactory="TaskHostFactory"only when$(MSBuildRuntimeType)isFull, and leave .NET MSBuild'sCoreregistration in-process. Runtime selection belongs on the registration so Framework MSBuild does not try to discover the .NET-only task in-process before selecting its host. Remove the redundant invocation-levelMSBuildRuntime="NET"override.Derive the task from
MultithreadedAndroidTaskand declare[MSBuildMultiThreadableTask]directly on it. Cover separate projects with relative paths and different resource mappings, including ordinary and strict multithreaded execution through both shipped registration surfaces.Recorded performance comparison
A captured MAUI
R.txtwith 6,817 lines was measured on an Apple M5 Max running macOS 26.7.1 and .NET 11 RC2 Arm64, using Release builds and BenchmarkDotNet 0.15.8 in-process with three warmups and eight measured iterations. These measurements were collected while both emitters and the temporary benchmark harness were present; they predate the subsequent framework-reference and task-environment changes.These are warm-process task timings, not end-to-end build speedups. Before removing the baseline, benchmark setup compared metadata contracts, public-key identity, normalized getter IL, and application property/field values. The development-only benchmark project and harness are not part of this PR.
Local validation
Validated the latest framework correction on macOS, with the branch based on
97cf5e2b7ca6ca73ed3c54b3ae1b6dd46d57a4c8:make all— passed; rebuilt the SDK and configured the local workload, with zero warnings and errors.dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj -v minimal --filter 'FullyQualifiedName~GenerateResourceDesignerAssemblyTests'— 25 passed; two Windows-only Framework MSBuild cases skipped on macOS.dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj -c Release -v minimal --filter 'FullyQualifiedName~GenerateResourceDesignerAssemblyTests'— 25 passed; the same two Windows-only cases skipped../dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter 'Name~ResourceDesignerBinaryLibraryCompatibility|Name~CheckResourceDesignerIsCreated'— eight passed; two unsupported NativeAOT Debug cases skipped. Includes normal/design-time framework metadata, existing binary-library compatibility, unchanged-output timestamps, resource regeneration, and C#/F# Debug/Release builds.Separately compiled the actual emitter and resource-parser source in a temporary project targeting
net11.0andnet12.0withLangVersion=preview,Features=updated-memory-safety-rules, andAllowUnsafeBlocks=false: both passed with zero warnings and errors. No unsafe block or suppression is needed in the emitter.The whole-project extended-safety experiment,
./dotnet-local.sh build src/Microsoft.Android.Build.Tasks/Microsoft.Android.Build.Tasks.csproj --no-restore -p:BuildProjectReferences=false -p:LangVersion=preview -p:Features=updated-memory-safety-rules -v:minimal, failed with four pre-existing CS9363 errors in linkedMetadataExtensions.cs, not in the emitter. Those helper boundaries are already addressed on main by #13189; this PR does not duplicate that opt-in or claim the whole-project experiment passed.Windows
MSBuild.exetask-host execution remains unverified locally. No issue is closed by this PR.Pull Request title and description should follow the
commit-messages.mdworkflow documentation, and in particular should include: