Skip to content

[build] Move CreateAssemblyStore to Microsoft.Android.Build.Tasks - #13198

Merged
simonrozsival merged 4 commits into
mainfrom
simonrozsival-move-createassemblystore-to-net11
Oct 23, 2026
Merged

simonrozsival merged 4 commits into
mainfrom
simonrozsival-move-createassemblystore-to-net11

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Moves the CreateAssemblyStore MSBuild task and its supporting types (AssemblyStoreBuilder, AssemblyStoreGenerator, AssemblyStoreGenerator.Classes, AssemblyStoreAssemblyInfo) from src/Xamarin.Android.Build.Tasks (netstandard2.0) to src/Microsoft.Android.Build.Tasks (net11.0) so that Xamarin.Android.Build.Tasks no longer depends on System.IO.Hashing.Crc32 for assembly store generation.

Changes

  • Moved CreateAssemblyStore, AssemblyStoreBuilder, AssemblyStoreGenerator, AssemblyStoreGenerator.Classes, and AssemblyStoreAssemblyInfo to src/Microsoft.Android.Build.Tasks under namespace Microsoft.Android.Tasks.
  • Computed assembly-name CRC-32 hashes directly in AssemblyStoreGenerator via System.IO.Hashing.Crc32.HashToUInt32 (preserving bytes.Length == 0 ? UInt32.MaxValue : Crc32.HashToUInt32 (bytes)) and removed the now-unused TypeMapHelper.HashBytesForCLR from src/Xamarin.Android.Build.Tasks/Utilities/TypeMapHelper.cs.
  • Added an explicit <PackageReference Include="System.IO.Hashing" Version="$(SystemIOHashingPackageVersion)" /> to src/Microsoft.Android.Build.Tasks/Microsoft.Android.Build.Tasks.csproj.
  • Updated src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets to register Microsoft.Android.Tasks.CreateAssemblyStore from $(_MicrosoftAndroidBuildTasksAssembly) and invoke <CreateAssemblyStore MSBuildRuntime="NET" ...>.
  • Moved CreateAssemblyStoreTests to src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/CreateAssemblyStoreTests.cs.

Validation

  • ./dotnet-local.sh build src/Microsoft.Android.Build.Tasks/Microsoft.Android.Build.Tasks.csproj: Passed (0 warnings, 0 errors)
  • ./dotnet-local.sh build src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj: Passed (0 warnings, 0 errors)
  • ./dotnet-local.sh test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj --filter "FullyQualifiedName~CreateAssemblyStoreTests": Passed (2/2 tests passed)

…t11.0)

Move CreateAssemblyStore and its supporting AssemblyStoreBuilder,
AssemblyStoreGenerator, AssemblyStoreGenerator.Classes, and
AssemblyStoreAssemblyInfo classes from Xamarin.Android.Build.Tasks
(netstandard2.0) to Microsoft.Android.Build.Tasks (net11.0), and move
CreateAssemblyStoreTests to Microsoft.Android.Build.Tasks.Tests.

Compute the assembly name CRC-32 directly via Crc32.HashToUInt32 in
AssemblyStoreGenerator and remove the now-unused TypeMapHelper.HashBytesForCLR
helper from Xamarin.Android.Build.Tasks.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 19, 2026 15:26

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

Reported builds and unit tests do not validate end-to-end Android packaging or cross-runtime loading of the relocated task.

No open issues 🎉

What changed in this PR

Moves assembly-store generation into the .NET 11 build-task project, removing its CRC-32 helper dependency on the legacy task project.

Changes:

  • Relocates the task, supporting types, and tests.
  • Preserves hashing semantics with a direct System.IO.Hashing dependency.
  • Updates MSBuild registration and selects the .NET task runtime.
File Description
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Common.targets Registers and invokes the relocated task.
src/​Xamarin.Android.Build.Tasks/​Utilities/​TypeMapHelper.cs Removes the unused CRC-32 helper.
src/​Microsoft.Android.Build.Tasks/​Utilities/​TaskItemExtensions.cs Adds a string metadata fallback overload.
src/​Microsoft.Android.Build.Tasks/​Utilities/​AssemblyStoreGenerator.cs Relocates generation and computes CRC-32 locally.
src/​Microsoft.Android.Build.Tasks/​Utilities/​AssemblyStoreGenerator.Classes.cs Updates the supporting types’ namespace.
src/​Microsoft.Android.Build.Tasks/​Utilities/​AssemblyStoreBuilder.cs Relocates the builder.
src/​Microsoft.Android.Build.Tasks/​Utilities/​AssemblyStoreAssemblyInfo.cs Relocates assembly metadata handling.
src/​Microsoft.Android.Build.Tasks/​Tests/​Microsoft.Android.Build.Tasks.Tests/​CreateAssemblyStoreTests.cs Moves tests and updates temporary paths.
src/​Microsoft.Android.Build.Tasks/​Tasks/​CreateAssemblyStore.cs Relocates the MSBuild task.
src/​Microsoft.Android.Build.Tasks/​Microsoft.Android.Build.Tasks.csproj Adds the hashing package reference.

Review effort: Balanced

simonrozsival and others added 2 commits October 19, 2026 17:30
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival changed the title [build] Move CreateAssemblyStore to Microsoft.Android.Build.Tasks (net11.0) [build] Move CreateAssemblyStore to Microsoft.Android.Build.Tasks Oct 20, 2026
@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Oct 22, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival enabled auto-merge (squash) October 23, 2026 10:38
@simonrozsival

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto

Copy link
Copy Markdown
Member

@simonrozsival Not reviewing this request in this iteration: the independent source-review worker failed before returning the complete coverage and candidate-disposition record needed to finish the review of head 6ef7bbe. Its preliminary empty-name CRC concern has not been verified on a supported task-to-native execution path, so I am not treating it as a proven blocker or submitting a review. A complete review remains outstanding.

@simonrozsival
simonrozsival merged commit a3c24de into main Oct 23, 2026
41 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-move-createassemblystore-to-net11 branch October 23, 2026 21:32
simonrozsival added a commit that referenced this pull request Oct 27, 2026
…oid.Build.Tasks (#13199)

Context: bf732908d0250966278042dc63a5f6f7ec2ca614
Context: 12c2d57
Context: 9e66448
Context: fa7d557
Context: a3c24de

`Xamarin.Android.Build.Tasks.dll` targets `netstandard2.0` so that MSBuild tasks can load in both .NET Framework (`MSBuild.exe` in Visual Studio) and .NET (`dotnet build`).  Because `netstandard2.0` does not include `System.IO.Hashing` in the shared framework, referencing `System.IO.Hashing` from `Xamarin.Android.Build.Tasks.csproj` deposits the `netstandard2.0` flavor of `System.IO.Hashing.dll` (whose `Span<T>` overloads bind to `System.Memory`) into the SDK's `tools/` directory.  As noted in bf73290, `net11.0` tasks had to be placed in `tools/net/Microsoft.Android.Build.Tasks.dll` so they would not resolve the `netstandard2.0` `System.IO.Hashing.dll` and fail with `MissingMethodException`.

After commits 9e66448 (#13197) and a3c24de (#13198) removed unused hashing helpers and moved `<CreateAssemblyStore/>` to `Microsoft.Android.Build.Tasks.dll`, `<GenerateNativeApplicationConfigSources/>` (via `CoreClrBootstrapBuilder`) was the last remaining consumer of `System.IO.Hashing.Crc32` in `Xamarin.Android.Build.Tasks.dll`.

Move `<GenerateNativeApplicationConfigSources/>` and its supporting types from `src/Xamarin.Android.Build.Tasks` (`netstandard2.0`) to `src/Microsoft.Android.Build.Tasks` (`net11.0`) so `Xamarin.Android.Build.Tasks.dll` no longer needs `System.IO.Hashing`:

  * Move `GenerateNativeApplicationConfigSources`, `CoreClrBootstrapBuilder`, `RuntimePropertiesParser`, and `BundleConfigSplitConfigsChecker` to `src/Microsoft.Android.Build.Tasks/` under `namespace Microsoft.Android.Tasks`.
  * Compute DSO cache entry hashes in `CoreClrBootstrapBuilder.Write()` directly via `System.IO.Hashing.Crc32.HashToUInt32()`, and add an explicit `System.IO.Hashing` `<PackageReference/>` to `Microsoft.Android.Build.Tasks.csproj`.
  * Remove the `CoreClrBootstrapBlob.cs` and `EnvironmentBuilder.cs` source links from `Xamarin.Android.Build.Tasks.csproj`, as all callers now reside in `Microsoft.Android.Build.Tasks.dll`.
  * Move `MonoAndroidHelper.GetAssemblyCulture()`, `ParseAndroidRuntime()`, and `GetNormalizedNativeLibraryName()` into the shared `MonoAndroidHelper.Assemblies.cs` file (using `.IsNullOrEmpty()` so `#nullable enable` compiles cleanly on `netstandard2.0` as well as `net11.0`), and move `ELFHelper.IsJniLibrary()` into `CoreClrBootstrapBuilder` while removing unused symbol-lookup helpers from `ELFHelper`.
  * Define `PackageNamingPolicy` in `Microsoft.Android.Tasks` so `Microsoft.Android.Build.Tasks.csproj` remains self-contained without referencing `Java.Interop.Tools.TypeNameMappings`.
  * Update `Xamarin.Android.Common.targets` to register `Microsoft.Android.Tasks.GenerateNativeApplicationConfigSources` from `$(_MicrosoftAndroidBuildTasksAssembly)` using the conditional `Full` (`TaskHostFactory`) / `Core` `Runtime="NET"` `<UsingTask/>` pattern from fa7d557 (#13195), and update `$(_AndroidCoreClrBootstrapTaskAssembly)` in the `_AndroidGenerateCoreClrBootstrapInputs` target to track `$(_MicrosoftAndroidBuildTasksAssembly)`.
  * Move `GenerateNativeApplicationConfigSourcesTests`, `RuntimePropertiesParserTests`, and `EnvironmentBuilderTests` to `Microsoft.Android.Build.Tasks.Tests`, generating synthetic 32-bit (`AndroidTargetArch.Arm`) and 64-bit (`AndroidTargetArch.Arm64`) ELF JNI libraries via `AssemblyStoreElfWriter` and `ELFReader` so the tests run standalone without requiring a native build of `libtest-jni-library.so`.
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