[CoreCLR] PublishReadyToRun fails for net10.0-android* on macOS: crossgen2 `Target OS 'android' is not supported`
- Dominant language
- C#
- Stars
- 2.1k
- Forks
- 579
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 252
Description
### 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 https://github.com/dotnet/android/pull/11477.
### Workaround applied
In https://github.com/dotnet/android/pull/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)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with DotNetInstallAndRunMinorAPILevels and the CoreCLR matrix workaround in dotnet/android#11477, then inspect Microsoft.Android.Sdk.CoreCLR.targets:17 and the SDK _CreateR2RImages path. Reproduce the net10.0-android36.1 Release+CoreCLR failure on macOS and compare it with net11.0-android*. Done means deciding whether to retain the workaround or make R2R work, then removing the workaround if appropriate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, csharp, macos
- Domain
- build-system, ci-cd, mobile
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100