Skip to content

[build] Move GenerateNativeApplicationConfigSources to Microsoft.Android.Build.Tasks - #13199

Merged
simonrozsival merged 6 commits into
mainfrom
simonrozsival-move-generate-native-app-config-sources
Oct 27, 2026
Merged

simonrozsival merged 6 commits into
mainfrom
simonrozsival-move-generate-native-app-config-sources

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

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 ([Microsoft.Android.Build.Tasks] Register all net11.0 tasks with conditional Runtime="NET" UsingTask #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.

Validation

  • ./dotnet-local.sh build build-tools/xa-prep-tasks/xa-prep-tasks.csproj — passed
  • ./dotnet-local.sh build src/Microsoft.Android.Build.Tasks/Microsoft.Android.Build.Tasks.csproj — passed
  • ./dotnet-local.sh build src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj -p:BuildProjectReferences=false -t:Compile — passed
  • ./dotnet-local.sh test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj --filter "FullyQualifiedName~GenerateNativeApplicationConfigSourcesTests|FullyQualifiedName~RuntimePropertiesParserTests|FullyQualifiedName~EnvironmentBuilderTests|FullyQualifiedName~NativeAotBootstrapTargetsTests" — passed (28/28)

Pull Request
title and
description
should follow the
commit-messages.md workflow documentation, and in particular should include:

  • Useful description of why the change is necessary.
  • Links to issues fixed
  • Unit tests

simonrozsival and others added 3 commits October 19, 2026 17:34
…oid.Build.Tasks

Move GenerateNativeApplicationConfigSources, CoreClrBootstrapBuilder,
RuntimePropertiesParser, and BundleConfigSplitConfigsChecker from
Xamarin.Android.Build.Tasks (netstandard2.0) to
Microsoft.Android.Build.Tasks (net11.0), and invoke the task with
MSBuildRuntime="NET" from _AndroidGenerateCoreClrBootstrap.

Compute the DSO cache CRC-32 directly via System.IO.Hashing.Crc32 in
CoreClrBootstrapBuilder and remove TypeMapHelper.HashNameForCLR so
Xamarin.Android.Build.Tasks no longer needs Crc32 for CoreCLR bootstrap
generation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…nal Runtime="NET" UsingTask

Match the pattern in #13195 by registering
Microsoft.Android.Tasks.GenerateNativeApplicationConfigSources with the
conditional Full/Core Runtime="NET" <UsingTask> declarations and
removing the redundant MSBuildRuntime="NET" attribute on the task
invocation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ootstrapBuilder

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival marked this pull request as ready for review October 19, 2026 16:08
Copilot AI balanced review requested due to automatic review settings October 19, 2026 16:08

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.

🟡 Changes recommended

The relocated helper introduces a nullable compilation error in the legacy netstandard2.0 task project.

1 open issue
What changed in this PR

Moves CoreCLR bootstrap generation into the modern .NET task assembly, removing its CRC-32 dependency from the legacy implementation.

Changes:

  • Relocates the task and supporting utilities.
  • Updates task registration and incremental-build tracking.
  • Migrates tests and adds registration checks.
File Description
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Common.targets Registers the moved task and tracks its assembly.
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Build.Tasks.csproj Removes obsolete source links.
src/​Xamarin.Android.Build.Tasks/​Utilities/​TypeMapHelper.cs Removes the CRC-32 helper.
src/​Xamarin.Android.Build.Tasks/​Utilities/​MonoAndroidHelper.cs Relocates shared helpers.
src/​Xamarin.Android.Build.Tasks/​Utilities/​ELFHelper.cs Removes relocated and unused ELF helpers.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​GeneratePackageManagerJavaTests.cs Removes migrated bootstrap tests.
src/​Microsoft.Android.Build.Tasks/​Utilities/​RuntimePropertiesParser.cs Moves parser namespace.
src/​Microsoft.Android.Build.Tasks/​Utilities/​MonoAndroidHelper.Assemblies.cs Hosts shared assembly and runtime helpers.
src/​Microsoft.Android.Build.Tasks/​Utilities/​CoreClrBootstrapBuilder.cs Implements hashing and JNI-library detection locally.
src/​Microsoft.Android.Build.Tasks/​Utilities/​BundleConfigSplitConfigsChecker.cs Moves checker namespace.
src/​Microsoft.Android.Build.Tasks/​Tests/​Microsoft.Android.Build.Tasks.Tests/​Tasks/​RuntimePropertiesParserTests.cs Updates parser imports.
src/​Microsoft.Android.Build.Tasks/​Tests/​Microsoft.Android.Build.Tasks.Tests/​Tasks/​GenerateNativeApplicationConfigSourcesTests.cs Migrates coverage and generates ELF fixtures.
src/​Microsoft.Android.Build.Tasks/​Tests/​Microsoft.Android.Build.Tasks.Tests/​Tasks/​EnvironmentBuilderTests.cs Relocates environment tests.
src/​Microsoft.Android.Build.Tasks/​Tests/​Microsoft.Android.Build.Tasks.Tests/​NativeAotBootstrapTargetsTests.cs Checks task registration and assembly tracking.
src/​Microsoft.Android.Build.Tasks/​Tests/​Microsoft.Android.Build.Tasks.Tests/​Microsoft.Android.Build.Tasks.Tests.csproj Links the bootstrap test helper.
src/​Microsoft.Android.Build.Tasks/​Tasks/​GenerateNativeApplicationConfigSources.cs Moves task namespace and resource references.
src/​Microsoft.Android.Build.Tasks/​Microsoft.Android.Build.Tasks.csproj Adds hashing dependency and shared runtime enum.

Review effort: Balanced

simonrozsival and others added 2 commits October 21, 2026 23:22
…blies.cs on netstandard2.0

Use the .IsNullOrEmpty() extension method (annotated with
[NotNullWhen(false)]) in GetAssemblyCulture and
GetNormalizedNativeLibraryName so that MonoAndroidHelper.Assemblies.cs
compiles without CS8602 when linked into Xamarin.Android.Build.Tasks
(netstandard2.0).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…g-sources

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers

Copy link
Copy Markdown
Member

/review

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #13199

@github-actions github-actions Bot 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.

No blocking code findings — 0 ❌ errors, 0 ⚠️ warnings, 1 💡 inline suggestion.

Reviewed all 16 changed files in full, checked callers and shared-source links, and compared the relocated JNI detection and naming-policy values with their previous implementations. The migration keeps the bootstrap generation self-contained in the modern task assembly, updates the incremental task-assembly input, and preserves environment-update and excluded-assembly coverage while removing the native fixture dependency. The inline suggestion concerns the synthetic ELF fixture's hard-coded byte offset.

CI: All 41 head-commit GitHub checks report success, including the aggregate dotnet-android check for Azure build 1646682. Direct Azure build/timeline verification could not be completed because az devops invoke requires authentication in this environment; the CI assessment is therefore limited to the GitHub-reported results. No local build or tests were run during this review.

Generated by Android PR Reviewer for #13199 · copilot · gpt61 · 55.6 AIC · ⌖ 7.9 AIC · ⊞ 19.1K
Comment /review to run again

… in GenerateNativeApplicationConfigSourcesTests

Derive the .dynsym section offset and symbol entry size from the ELF
section header in WriteTestJniLibrary (handling both Elf64_Sym and
Elf32_Sym st_info offsets), and include a 32-bit ARM (AndroidTargetArch.Arm)
JNI library in the test fixture.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@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 27, 2026
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #13199

@github-actions github-actions Bot 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.

Code assessment: no blocking findings. 0 ❌ errors, 0 ⚠️ warnings, 1 💡 inline suggestion to assert the serialized DSO hashes directly.

The task/helper relocation preserves the existing bootstrap construction, JNI symbol check, runtime-property parsing, and shared helper behavior. The new package-naming enum matches the original numeric values, the task registrations follow the existing Full/Core pattern, and the incremental input now tracks the relocated task assembly. The self-contained 32-/64-bit ELF fixtures are a useful improvement over depending on a prebuilt JNI test library.

⚠️ CI verification limited: all 41 GitHub check runs report success, including the overall dotnet-android check for Azure build 1650429. Direct Azure build/timeline verification could not be completed because the Azure CLI required authentication. No unconditional CI-green verdict is asserted.

Generated by Android PR Reviewer for #13199 · copilot · gpt61 · 52.1 AIC · ⌖ 7.25 AIC · ⊞ 19.3K
Comment /review to run again

@simonrozsival
simonrozsival merged commit 7c86c9b into main Oct 27, 2026
41 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-move-generate-native-app-config-sources branch October 27, 2026 14:01
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.

3 participants