Repository navigation
[Microsoft.Android.Build.Tasks] Register all net11.0 tasks with conditional Runtime="NET" UsingTask - #13195
Merged
Conversation
…tional Runtime="NET" UsingTask Tasks in `Microsoft.Android.Build.Tasks.dll` target `net11.0`. On .NET Framework MSBuild (`$(MSBuildRuntimeType) == 'Full'`), loading a `net11.0` task assembly without `TaskFactory="TaskHostFactory"` and `Runtime="NET"` on `<UsingTask>` fails or attempts in-process loading on .NET Framework 4.7.2, while on .NET MSBuild (`$(MSBuildRuntimeType) == 'Core'`), `Runtime="NET"` runs in-process without spawning an out-of-proc task host. Update all remaining `<UsingTask>` registrations for `$(_MicrosoftAndroidBuildTasksAssembly)` to use the standard two-line `Full` / `Core` conditional registration pattern and remove redundant `MSBuildRuntime="NET"` attributes from task invocations. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The Windows task-host path has a compression-cache regression and lacks integration validation.
1 open issue
What changed in this PR
Centralizes runtime selection for modern .NET Android build tasks across Visual Studio and dotnet build.
Changes:
- Adds conditional Full/Core task registrations.
- Removes invocation-level runtime overrides.
- Updates explanatory comments; task implementations are unchanged.
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | Updates packaging and compression task registrations. |
| src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Javac.targets | Updates Java archive task registration. |
| src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Assets.targets | Updates asset-pack task registration. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Proguard.targets | Adds runtime selection for typemap tasks. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.R8JniRemapping.targets | Updates remapping task runtime selection. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets | Updates NativeAOT task runtime selection. |
| src/Microsoft.Android.Build.Tasks/Tasks/CompressAssemblies.cs | Updates runtime-selection documentation only. |
| src/Microsoft.Android.Build.Tasks/Microsoft.Android.Build.Tasks.csproj | Updates assembly-purpose comments only. |
Review effort: Balanced
simonrozsival
added a commit
that referenced
this pull request
Oct 19, 2026
…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>
2 of 3 tasks
simonrozsival
enabled auto-merge (squash)
October 20, 2026 15:01
jonathanpeppers
approved these changes
Oct 20, 2026
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`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary of Changes
<UsingTask>registrations for$(_MicrosoftAndroidBuildTasksAssembly)across.targetsfiles (Xamarin.Android.Common.targets,Xamarin.Android.Assets.targets,Xamarin.Android.Javac.targets,Microsoft.Android.Sdk.NativeAOT.targets,Microsoft.Android.Sdk.R8JniRemapping.targets, andMicrosoft.Android.Sdk.TypeMap.Proguard.targets) to use the standard two-line conditionalFull/Corepattern:Microsoft.Android.Build.Tasks.dll(net11.0) runs out-of-proc viaTaskHostFactorywithRuntime="NET"on Visual Studio (MSBuild.exe,$(MSBuildRuntimeType) == 'Full') and in-proc withRuntime="NET"ondotnet build($(MSBuildRuntimeType) == 'Core').MSBuildRuntime="NET"attributes from task invocations now that<UsingTask>specifiesRuntime="NET".Microsoft.Android.Build.Tasks.csprojandCompressAssemblies.csto reference<UsingTask ... Runtime="NET" />.Contributes to / Resolves
Verification
dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj— passed (727 passed, 12 skipped, 0 failed)dotnet build src/Microsoft.Android.Build.Tasks/Microsoft.Android.Build.Tasks.csproj— passed (0 warnings, 0 errors)dotnet build src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj -p:DisableApiCompatibilityCheck=true— passed (0 warnings, 0 errors)<UsingTask ... AssemblyFile="$(_MicrosoftAndroidBuildTasksAssembly)" />orMSBuildRuntime="NET"remain insrc/.Documentation