Skip to content

[CoreCLR] PublishReadyToRun fails for net10.0-android* on macOS: crossgen2 Target OS 'android' is not supported #11719

Description

@jonathanpeppers

Context

DotNetInstallAndRunMinorAPILevels(True, "net10.0-android36.1", CoreCLR) fails on macOS CI with the following error from CrossGen2 (ilc / R2R compilation) inside _CreateR2RImages:

Microsoft.NET.CrossGen.targets(501,5): error : Unhandled exception. System.CommandLine.CommandLineException: Target OS ''android'' is not supported
  at System.CommandLine.Helpers.GetTargetOS(String) + 0x64a
  at ILCompiler.Program.Main(String[] args) + 0xef

Scope

This affects net10.0-android* projects only. net11.0-android* projects (the default $(DotNetTargetFramework) on main) are fine because they pick up the matching .NET 11 SDK whose crossgen2 understands --targetos android.

CoreCLR-on-Android is experimental in .NET 10, so this is low priority — but it does break Release+CoreCLR builds targeting the older TFM on the new SDK.

Suspected cause

The .NET 10 SDK's R2R compiler (crossgen2 / ilc) does not recognise android as a valid --targetos. Microsoft.Android.Sdk.CoreCLR.targets:17 auto-enables PublishReadyToRun=true in Release+CoreCLR, which then routes through the SDK''s _CreateR2RImages target and invokes the in-box crossgen2. For a net10.0-android* project that picks up the .NET 10 crossgen2, which blows up; a net11.0-android* project picks up the .NET 11 crossgen2, which works.

The breakage surfaced after the dotnet/dotnet SDK bump in #11477.

Workaround applied

In #11477 the test was modified to set PublishReadyToRun=false for the CoreCLR matrix entry, so the test exercises Install+Run without R2R. The MonoVM and NativeAOT matrix entries are unaffected.

What to do here

  • Decide whether to fix anything: CoreCLR-on-Android is experimental in .NET 10, so leaving net10.0-android* users to opt out of R2R explicitly may be acceptable
  • If we do fix it, either teach the .NET 10 crossgen2 to accept --targetos android, or have Mono.Android''s CoreCLR targets auto-disable PublishReadyToRun when targeting net10.0-android*
  • Remove the workaround in DotNetInstallAndRunMinorAPILevels once R2R works (or once we drop the net10.0-android36.1 matrix entry)

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssues that need to be assigned.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions