Skip to content

Conversation

davidnguyen-tech
Copy link
Member

@davidnguyen-tech davidnguyen-tech commented Jul 11, 2025

Description

Forward the InvariantGlobalization MSBuild property to the CoreCLR runtime for Android applications by connecting the existing infrastructure.

Related issues

Fixes #117270

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables passing the InvariantGlobalization MSBuild property through the Android build pipeline so that Android apps can opt into invariant globalization mode at runtime.

  • Forwards the InvariantGlobalization property in test builds, Android build targets, and app tasks
  • Exposes a new InvariantGlobalization property on AndroidAppBuilderTask and propagates it into ApkBuilder
  • Removes the exclusion of the invariant globalization tests so they run against Android CoreCLR

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tests/build.proj Adds InvariantGlobalization to the test project invocation parameters
src/tasks/AndroidAppBuilder/ApkBuilder.cs Injects DOTNET_SYSTEM_GLOBALIZATION_INVARIANT when InvariantGlobalization is true
src/tasks/AndroidAppBuilder/AndroidAppBuilder.cs Declares InvariantGlobalization on the task and forwards it to ApkBuilder
src/mono/msbuild/android/build/AndroidBuild.targets Passes the MSBuild InvariantGlobalization property to the Android build targets
src/libraries/tests.proj Removes the exclusion for the invariant globalization tests
Comments suppressed due to low confidence (2)

src/tasks/AndroidAppBuilder/AndroidAppBuilder.cs:149

  • There are no tests verifying that InvariantGlobalization flows through the task to the APK and sets the correct environment variable. Consider adding a unit or integration test to validate this behavior.
        apkBuilder.InvariantGlobalization = InvariantGlobalization;

src/tasks/AndroidAppBuilder/ApkBuilder.cs:427

  • The InvariantGlobalization property is referenced here but the ApkBuilder class does not define it. Add a public bool InvariantGlobalization { get; set; } property to ApkBuilder to ensure this compiles.
        if (InvariantGlobalization)

@davidnguyen-tech davidnguyen-tech changed the title [Android] Enable InvariantGlobalization support for Android builds [Android] Enable InvariantGlobalization support for CoreCLR Android builds Jul 11, 2025
@davidnguyen-tech davidnguyen-tech changed the title [Android] Enable InvariantGlobalization support for CoreCLR Android builds [Android] InvariantGlobalization support for CoreCLR Android builds Jul 11, 2025
@davidnguyen-tech
Copy link
Member Author

@dotnet-policy-service agree company="Microsoft"

Copy link
Contributor

Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

@kotlarmilos
Copy link
Member

/azp run runtime-android,runtime-androidemulator

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Member

@kotlarmilos kotlarmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check if the other globalization failures are resolved with this PR. Otherwise, LGTM!

@kotlarmilos
Copy link
Member

/azp run runtime-android,runtime-androidemulator

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@davidnguyen-tech
Copy link
Member Author

/azp run runtime-android,runtime-androidemulator

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Member

@kotlarmilos kotlarmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kotlarmilos
Copy link
Member

/ba-g android emulators capacity problem

@davidnguyen-tech davidnguyen-tech merged commit 4127516 into dotnet:main Jul 16, 2025
159 of 171 checks passed
@akoeplinger
Copy link
Member

@davidnguyen-tech @kotlarmilos does this mean coreclr doesn't read the runtimeconfig.json yet? cause it should be set there afaik.

@akoeplinger
Copy link
Member

I just saw the discussion with @vitek-karas in #117542 (comment), I agree that passing this through EnvironmentVariables is better and we can get rid of the workaround once coreclr android supports reading runtimeconfig.json.

The InvariantGlobalization property on ApkBuilder looks like a leftover

@davidnguyen-tech
Copy link
Member Author

davidnguyen-tech commented Jul 16, 2025

@akoeplinger I agree - since it seems like nobody's using the property, I will refactor it to be passed through EnvironmentVariables and get rid of the property. Thanks for pointing it out!

@davidnguyen-tech davidnguyen-tech deleted the issue-117270 branch July 16, 2025 13:35
@davidnguyen-tech davidnguyen-tech restored the issue-117270 branch July 16, 2025 13:36
@vitek-karas
Copy link
Member

we can get rid of the workaround once coreclr android supports reading runtimeconfig.json

Just to clarify - the proper Android hosting from dotnet/android does support this already. The problem is with the simple test host we use in dotnet/runtime. We've discussed this with @davidnguyen-tech and it's probably not worth the effort yet to implement something in the simple test host.

@akoeplinger
Copy link
Member

@vitek-karas hmm not sure I agree with that, there are likely other important settings you'll miss and all other hosts are implementing it.

I see that this is implemented in https://github.com/dotnet/android/blob/868acb2ceab4f97a5c261e8288500f2e3e2f8901/src/native/clr/host/host.cc#L33, can we not provide a simple implementation of get_runtime_property in dotnet/runtime? We already have the runtimeconfig.bin conversion code so you don't need to parse json.

@vitek-karas
Copy link
Member

@akoeplinger - we were discussing exactly that. For this specific problem we don't need it, because the knob has an env. variable. I just wanted to "Wait" until we find a case where we do need a knob which doesn't have env. variable - and implement it then.
But if David wants to pick it up right now, it's likely not a throw away work.

@akoeplinger
Copy link
Member

ok, makes sense

@davidnguyen-tech
Copy link
Member Author

The runtimeconfig.json support for our test host is tracked in #117919.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] Invariant.Tests.csproj is failing on CoreCLR Android

4 participants