Repository navigation
[build] Move CreateAssemblyStore to Microsoft.Android.Build.Tasks - #13198
Conversation
…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>
There was a problem hiding this comment.
🔵 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.Hashingdependency. - 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
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@dalexsoto review |
|
@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. |
…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`.
Moves the
CreateAssemblyStoreMSBuild task and its supporting types (AssemblyStoreBuilder,AssemblyStoreGenerator,AssemblyStoreGenerator.Classes,AssemblyStoreAssemblyInfo) fromsrc/Xamarin.Android.Build.Tasks(netstandard2.0) tosrc/Microsoft.Android.Build.Tasks(net11.0) so thatXamarin.Android.Build.Tasksno longer depends onSystem.IO.Hashing.Crc32for assembly store generation.Changes
CreateAssemblyStore,AssemblyStoreBuilder,AssemblyStoreGenerator,AssemblyStoreGenerator.Classes, andAssemblyStoreAssemblyInfotosrc/Microsoft.Android.Build.Tasksundernamespace Microsoft.Android.Tasks.AssemblyStoreGeneratorviaSystem.IO.Hashing.Crc32.HashToUInt32(preservingbytes.Length == 0 ? UInt32.MaxValue : Crc32.HashToUInt32 (bytes)) and removed the now-unusedTypeMapHelper.HashBytesForCLRfromsrc/Xamarin.Android.Build.Tasks/Utilities/TypeMapHelper.cs.<PackageReference Include="System.IO.Hashing" Version="$(SystemIOHashingPackageVersion)" />tosrc/Microsoft.Android.Build.Tasks/Microsoft.Android.Build.Tasks.csproj.src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targetsto registerMicrosoft.Android.Tasks.CreateAssemblyStorefrom$(_MicrosoftAndroidBuildTasksAssembly)and invoke<CreateAssemblyStore MSBuildRuntime="NET" ...>.CreateAssemblyStoreTeststosrc/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)