Repository navigation
[Build] Replace resource designer signing helpers with .NET APIs - #13110
Conversation
The generated designer assembly runs on modern .NET, where strong-name signatures are not validated or used for assembly binding. Keep its assembly identity without carrying the signing key and conversion helpers. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Incremental builds can retain the previously strong-named designer assembly after an SDK upgrade.
2 open findings
What changed in this PR
Removes strong-name metadata and related signing dependencies from generated resource designer assemblies.
Changes:
- Removes strong-name generation, signing helpers, and embedded key.
- Removes obsolete third-party notices and inventory entries.
- Preserves assembly name, version, and generation behavior.
| File | Description |
|---|---|
THIRD-PARTY-NOTICES.TXT |
Removes StrongNameSigner notice. |
.github/skills/update-tpn/SKILL.md |
Updates vendored dependency inventory. |
Xamarin.Android.Build.Tasks.csproj |
Removes signing helper sources. |
GenerateResourceDesignerAssembly.cs |
Stops adding strong-name metadata. |
SigningHelper.cs |
Deletes strong-name helper. |
CryptoConvert.cs |
Deletes key conversion helper. |
Resource.Designer.snk |
Removes embedded signing key. |
🧠 Review effort: Balanced
Invalidate designer assemblies when the Android SDK/task generator changes, and regenerate stale signed outputs. Remove the task-level timestamp shortcut and correct the vendored-source inventory. Co-authored-by: Copilot App <[email protected]>
Keep the design-time resource designer target scoped to R.txt freshness; the supported scenario does not require detecting SDK version changes in existing intermediate outputs. Co-authored-by: Copilot App <[email protected]>
The task implementation is fixed for an SDK installation; don't invalidate normal resource generation based on its assembly timestamp. Co-authored-by: Copilot App <[email protected]>
Skip designer generation when R.txt is older than the existing output, preserving incremental builds after resource-only changes while retaining strong-name removal. Co-authored-by: Copilot App <[email protected]>
Preserve both upstream CRC32.NET removal and this PR's StrongNameSigner removal in third-party notices and the audit inventory. Co-authored-by: Copilot App <[email protected]>
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
The complete seven-file correctness review and separate integration pass leave one compiler-binding incompatibility, independent of the accepted unsigned-runtime-output and retain-until-regenerated policies.
[P1] Preserve compiler binding for existing resource-bearing binary libraries. GenerateResourceDesignerAssembly.cs:205-207 removes the public-key identity while preserving name/version. A previously published library's public Resource class still inherits the strongly referenced _Microsoft.Android.Resource.Designer.Resource type, but the new SDK supplies an unsigned designer through ReferencePath. Accessing OldLibrary.Resource.String.hello therefore reaches the missing-assembly/CS0012 path: Roslyn explicitly rejects a strong reference against an unsigned definition (identity comparer, resolution loop). Relaxed runtime binding does not repair compilation, regenerating the app does not regenerate a published binary library, and publish/link fixups happen after this failure.
Keep runtime outputs unsigned, but provide a compiler-compatible reference or pre-compilation retargeting strategy for these existing references. Cover a pre-change binary library's public Resource access and mixed incremental outputs, rather than only projects rebuilt with the new generator. This respects the chosen unsigned design and does not request forced regeneration or restoration of signing helpers. The stale signed-output concern is treated under the current accepted retention policy; inventory removal is verified. No additional high-confidence blocker remains. This evidence is static source analysis, not an executed compiler/device reproduction.
Roslyn rejects a historical strong assembly reference against an unsigned\ndesigner definition, even though modern .NET does not validate signatures.\nRetain the original public key as metadata without restoring the private\nkey, cryptographic signing, or the removed third-party helpers.\n\nCover public Resource access through an unchanged legacy binary alongside\na newly built project reference, in normal and design-time builds. Check\nidentity, absence of signatures, no-op timestamps, and regeneration. Co-authored-by: Copilot App <[email protected]>
|
@dalexsoto Fixed in 7184c92. I reproduced the compiler failure: accessing After discussing the compatibility tradeoff, we chose to retain only the historical public-key metadata. The generated designer keeps the same name, version, and token, without a private key or cryptographic signature; the deleted StrongNameSigner/CryptoConvert helpers stay deleted. The PR title and description now distinguish compiler identity from modern-.NET runtime signature validation. Added normal/design-time regression coverage that consumes an unchanged binary carrying the historical reference alongside a freshly built project reference. It checks public Resource access, token/version, absence of the StrongNameSigned flag, no-op timestamp preservation, and successful regeneration after adding a resource without changing the binary library. Both new cases and the two prior incremental regressions pass (4/4) with the freshly built task injected into the installed SDK. The test project builds successfully. Full SDK validation remains blocked by the missing API 37.1 reference Mono.Android.dll; exact commands and results are recorded in the PR description. No forced upgrade invalidation is introduced. |
dalexsoto
left a comment
There was a problem hiding this comment.
The previous CS0012 compatibility blocker is fixed. The public-key-metadata-only repair preserves the historical designer name/version/token while removing private signing material and helpers; Cecil's metadata/writer behavior retains compiler identity without setting StrongNameSigned or creating a cryptographic signature. The normal/design-time binary/project-reference and incremental regression paths received source review, and the accepted retain-until-normal-regeneration policy remains unchanged.
The complete current eight-file correctness and separate integration review, candidate resolution and final independent search found no high-confidence blocker. This is source approval, not a green-CI or executed-test claim: both investigated macOS failures occur during CLI first-use before project evaluation, with no PR execution path causing that startup exception. Its underlying cause remains unresolved. The author's full locally packaged API 37.1 SDK validation is still incomplete and is not being reported as passed.
Restore CryptoConvert, StrongNameSigner, their project links and notices. Those changes belong to #13110, not the resource designer emitter change. Keep Resource.Designer.snk at its existing location and link that resource from the modern task project instead of moving it in this PR. Co-authored-by: Copilot App <[email protected]>
Restore the existing embedded resource-designer build key unchanged. Use RSACryptoServiceProvider.ImportCspBlob and ExportCspBlob(false) instead of embedding its public key as a base64 literal or restoring third-party key conversion helpers. Normalize the public CAPI algorithm identifier to CALG_RSA_SIGN because Unix exports CALG_RSA_KEYX. This preserves the historical compiler identity and public-key token without generating a signature or changing incremental invalidation. 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]>
dalexsoto
left a comment
There was a problem hiding this comment.
The unchanged embedded build key is exported public-only, and the normalized CAPI header preserves historical compiler identity without a cryptographic signature; existing resource, mixed-reference and incremental consumers remain consistent. The supported-platform BCL/resource/error paths and current-main deterministic timestamp integration received source review; the accepted retain-until-normal-regeneration policy is unchanged.
Document the historical SHA1 identity for CodeQL and reuse a pooled stream for importing the embedded key and serializing its public-key header. Co-authored-by: Copilot App <[email protected]>
|
@simonrozsival Not reviewing this request in this iteration: the source-only pass for head 489946b is complete, but its current build 1646688 has unresolved device-test failures: APKs 1 reports upload-reset cancellations and test-process crashes (Debug, Release and NoAab), and MSBuild+Emulator 2 fails DotNetRunWithDeviceParameter because the expected application message is absent. The published device-run log shows successful deployment, but does not establish the cause of the missing message; the crashes are not yet correlated with a verified baseline or matching known issue. I cannot safely classify these failures as unrelated to this change. No approval or change-request review has been submitted for this head. |
Avoid the MemoryStream.CopyToAsync fast path in the upload-reset regression test. Its single 16 MiB write marshals the entire array into Java and aborts devices with a 16 MiB heap before the intended connection reset. Preserve the payload, seekability, rewind and exception-chain assertions while copying through the requested small buffer. Use the existing ActivityStartTimeoutInSeconds budget for both dotnet-run output waits. Deployment and am start -W consumed the previous 60-second budget in CI even though the app emitted its marker. Local validation: make prepare and make all passed. Four resource-designer compatibility/incremental cases and four dotnet-run device cases passed. All 22 AndroidMessageHandlerUpload cases passed on arm64 with a 16 MiB Java app heap in Debug, Release AAB, and APK-only Release. Co-authored-by: Copilot App <[email protected]>
|
@simonrozsival Not reviewing this request in this iteration: the complete source/static pass for head b2ff9d7 found no source blocker, but build 1646954 stopped its MSBuild+Emulator 3 device-test leg while restoring Microsoft.Build.NoTargets, with NuGet service-index failures. That provisioning failure remains unclassified, so the affected device-test coverage is not established. ResolveSdkTiming separately matches a verified pre-existing main failure and is not the reason for this deferral. No monitor approval or change-request review has been submitted for this head. |
dalexsoto
left a comment
There was a problem hiding this comment.
The .NET RSA/CAPI replacement preserves the designer's historical assembly identity and correctly handles the pooled stream without reintroducing signing. The previously missing MSBuild+Emulator 3 device-test leg has now completed successfully on this head. The remaining ResolveSdkTiming failure matches the verified main baseline and is not a blocker for this change.
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]>
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]>
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]>
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]>
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]>
Context: #13110 Context: https://github.com/dotnet/runtime/blob/796e892b9fb442e08cae8366c27e2cbde3f08c72/src/native/corehost/host_runtime_contract.h The remaining src-ThirdParty layout mixes unused trimming/compiler polyfills with first-party CoreCLR hosting headers. Remove the unused sources and ThirdPartySourcePath, and move the hosting headers to src/native/clr/include/runtime. Keep the existing netstandard nullable-annotation shims and the two Android platform-tools sources unchanged. Update CMake includes and MSBuild native inputs for the relocated headers. Refresh host_runtime_contract.h verbatim from dotnet/runtime/main at 796e892b9fb442e08cae8366c27e2cbde3f08c72. Explicitly initialize the new optional callbacks to nullptr, preserving existing assembly-resolution behavior without introducing missing-initializer warnings. Move coreclrhost.h and README without content changes. Validation: full SDK builds passed, including ARM/ARM64/x64 native Debug and Release builds; 19 focused host tests and 6 CoreCLR RuntimeConfig tests on an ARM64 API 35 emulator passed. 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]>
…#13150) Context: [#13110](#13110) preserves the resource designer's historical public-key identity without signing the generated assembly. [#13144](#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.GenerateResourceDesignerAssembly` with a .NET-only task in `Microsoft.Android.Build.Tasks` that writes metadata, IL, and the PE image directly with `System.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.0` and public-key token `1e9360d6629057ee` so existing binary libraries continue to compile against the generated designer. Read the public key from the existing embedded `Resource.Designer.snk`; do not sign the generated assembly or move the key file. Generate `TargetFrameworkAttribute` from the project's `$(TargetFrameworkIdentifier)` and `$(TargetFrameworkVersion)`, and scope framework type references to the matching `System.Runtime` version instead of retaining the old `netstandard2.1` baseline. 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's `TaskEnvironment`; use the project-scoped copy/retry overload rather than cached process-wide environment settings. Use `CultureInfo.InvariantCulture` for resource IDs, styleable indices, map keys, and parser diagnostics. Culture tests exercise `ar-SA` and `tr-TR` with 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: declare `Runtime="NET"` for both hosts, select `TaskFactory="TaskHostFactory"` only when `$(MSBuildRuntimeType)` is `Full`, and leave .NET MSBuild's `Core` registration 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-level `MSBuildRuntime="NET"` override. Derive the task from `MultithreadedAndroidTask` and 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.txt` with 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. | Fresh generation | Cecil mean ± SD | Metadata mean ± SD | Speedup | Managed allocation reduction | |---|---:|---:|---:|---:| | Library | 20.817 ± 0.328 ms | 8.115 ± 0.182 ms | 2.56× | 57% | | Application | 25.492 ± 0.689 ms | 8.639 ± 0.091 ms | 2.95× | 60% | 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.
Backport only the AndroidMessageHandlerUploadTests change from 9d70f2f (#13110). Bound each upload write to avoid exhausting small Java heaps. Co-authored-by: Copilot App <[email protected]>


Summary
Replace the vendored StrongNameSigner and CryptoConvert helpers with built-in .NET RSA APIs. Keep the existing embedded
Resources/Resource.Designer.snkunchanged and extract its public key withRSACryptoServiceProvider.ImportCspBlobandExportCspBlob(false), rather than hardcoding a Base64 public key. Remove the obsolete helper sources, project entries, and StrongNameSigner third-party notice.The generated
_Microsoft.Android.Resource.Designerkeeps its historical name, version, and public-key token (1e9360d6629057ee). The exported CAPI public blob is wrapped in the strong-name public-key header and its algorithm identifier is normalized toCALG_RSA_SIGN, including on Unix where .NET exportsCALG_RSA_KEYX. No cryptographic signature is generated.Why
Microsoft's strong-name guidance explains that strong names provide identity, not security, and that modern .NET neither validates strong-name signatures nor uses them for runtime assembly binding.
Compiler compatibility is different: Roslyn still checks assembly identities. Removing the designer's public-key metadata causes
CS0012when an app accesses the publicResourceclass of a previously compiled binary library whose base type references the historical designer identity. This was reproduced locally. The public key therefore remains as compatibility metadata; neither the third-party conversion code nor actual signing is needed. The generated designer has noStrongNameSignedmodule flag.Keeping the existing SNK resource also avoids an opaque hardcoded key literal. It is the same publicly checked-in build key as before this PR, not a new credential. No SNK-specific exemption was found in the checked-in Guardian suppressions; no scanning suppression is added or broadened.
Existing designer outputs remain valid until normal resource changes regenerate them. The existing timestamp shortcut and target inputs are preserved; no forced SDK-upgrade invalidation is added.
Regression coverage
ResourceDesignerBinaryLibraryCompatibilityexercises normal and design-time builds with an unchanged binary library carrying the historical designer reference alongside a freshly built project reference. It accesses both libraries' public resources, checks the historical version/token and absence of a signature, verifies no-op builds retain the designer timestamp, and regenerates the app designer after adding a resource without modifying the binary library.Validation
./dotnet-local.sh build src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj -c Debug --no-restore -v:quiet(30 warnings, 0 errors).TEST_ANDROID_JDK_PATH=/Users/simon/android-toolchain/jdk-21 TEST_ANDROID_SDK_PATH=/Users/simon/Library/Android/sdk CustomBeforeMicrosoftCommonTargets=/Users/simon/.copilot/session-state/5ede0cc5-2430-49a7-bf91-18f1165d0e66/files/resource-designer-task-override.targets ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter 'Name~ResourceDesignerBinaryLibraryCompatibility|Name~AndroidResourceChange&Name~CoreCLR|Name~RepetiviteBuildUpdateSingleResource&Name~CoreCLR'(4/4 passed). The session-local override registers the freshly builtGenerateResourceDesignerAssemblytask in the installed SDK; these results exercise the new SNK extraction rather than the stock task.git diff --check;git hash-object src/Xamarin.Android.Build.Tasks/Resources/Resource.Designer.snkmatchesgit rev-parse origin/main:src/Xamarin.Android.Build.Tasks/Resources/Resource.Designer.snkexactly.make prepare && make all— preparation succeeds, butCreateFrameworkListFilefails becausebin/Debug/lib/xamarin.android/xbuild-frameworks/Microsoft.Android/37.1/ref/Mono.Android.dllis missing. Full locally packaged SDK validation remains incomplete. Windows/Linux execution of the extraction is not locally verified on this macOS host.No linked issue.
Pull Request
title and
description
should follow the
commit-messages.mdworkflow documentation, and in particular should include: