Skip to content

[Xamarin.Android.Build.Tasks] Set UseMonoRuntime for Debug configuration#10662

Merged
jonathanpeppers merged 2 commits intomainfrom
dev/srozsival/use-mono-runtime-for-debug
Jan 6, 2026
Merged

[Xamarin.Android.Build.Tasks] Set UseMonoRuntime for Debug configuration#10662
jonathanpeppers merged 2 commits intomainfrom
dev/srozsival/use-mono-runtime-for-debug

Conversation

@simonrozsival
Copy link
Member

This is a follow-up to #10527 which made CoreCLR the default runtime. We still need to use MonoVM in Debug mode until we have full debugger support.

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

@simonrozsival do you have a .binlog to see if this works?

I'm wondering if $(Configuration) is blank at the point this file is imported.

<_GetChildProjectCopyToPublishDirectoryItems>false</_GetChildProjectCopyToPublishDirectoryItems>
<_AndroidRuntime Condition=" '$(PublishAot)' == 'true' ">NativeAOT</_AndroidRuntime>
<_AndroidRuntime Condition=" '$(PublishAot)' != 'true' and '$(UseMonoRuntime)' == 'true' ">MonoVM</_AndroidRuntime>
<_AndroidRuntime Condition=" '$(PublishAot)' != 'true' and ('$(UseMonoRuntime)' == 'true' or '$(Configuration)' == 'Debug') ">MonoVM</_AndroidRuntime>
Copy link
Member

Choose a reason for hiding this comment

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

We could use $(AndroidDebugSymbols) as it works for any $(Configuration) that is setup to be "debuggable":

<Choose>
<When Condition=" '$(DebugSymbols)' == 'True' And '$(DebugType)' != '' And ('$(EmbedAssembliesIntoApk)' == 'False' Or '$(Optimize)' != 'True') ">
<PropertyGroup>
<AndroidIncludeDebugSymbols>True</AndroidIncludeDebugSymbols>
</PropertyGroup>
</When>
<When Condition=" '$(DebugSymbols)' != '' And $(DebugSymbols) And '$(DebugType)' == '' ">
<PropertyGroup>
<AndroidIncludeDebugSymbols>True</AndroidIncludeDebugSymbols>
</PropertyGroup>
</When>
<When Condition=" '$(EmbedAssembliesIntoApk)' == 'False' ">
<PropertyGroup>
<AndroidIncludeDebugSymbols>True</AndroidIncludeDebugSymbols>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<AndroidIncludeDebugSymbols>False</AndroidIncludeDebugSymbols>
</PropertyGroup>
</Otherwise>
</Choose>

But the problem is ordering... This file runs after Microsoft.Android.Sdk.DefaultProperties.targets‎.

If this change is temporary, maybe this is fine for now.

@simonrozsival
Copy link
Member Author

@jonathanpeppers this is how I verified it locally:

Simons-MacBook @ ~/Projects/dotnet/playground/TestAndroid   
> dotnet new android

Simons-MacBook @ ~/Projects/dotnet/playground/TestAndroid   
>_ ../../android/dotnet-local.sh build -r android-arm64 -getProperty:_AndroidRuntime
No .NET SDKs were found.

Download a .NET SDK:
https://aka.ms/dotnet/download

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
MonoVM

Simons-MacBook @ ~/Projects/dotnet/playground/TestAndroid   
>_ ../../android/dotnet-local.sh build -r android-arm64 -c Release -getProperty:_AndroidRuntime
No .NET SDKs were found.

Download a .NET SDK:
https://aka.ms/dotnet/download

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
CoreCLR

To further verify, I ran ../../android/dotnet-local.sh build -r android-arm64 -preprocess > preprocessed-debug.xml, the $(Configuration) property is set very early (global property on line 390, included from Microsoft.NET.Sdk.props), and the $(_AndroidRuntime) global property is set later (global property set on line 2406).

<_GetChildProjectCopyToPublishDirectoryItems>false</_GetChildProjectCopyToPublishDirectoryItems>
<_AndroidRuntime Condition=" '$(PublishAot)' == 'true' ">NativeAOT</_AndroidRuntime>
<_AndroidRuntime Condition=" '$(PublishAot)' != 'true' and '$(UseMonoRuntime)' == 'true' ">MonoVM</_AndroidRuntime>
<_AndroidRuntime Condition=" '$(PublishAot)' != 'true' and ('$(UseMonoRuntime)' == 'true' or '$(Configuration)' == 'Debug') ">MonoVM</_AndroidRuntime>
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the test failures, I think we need to add back:

    <UseMonoRuntime Condition=" '$(UseMonoRuntime)' == '' and '$(Configuration)' == 'Debug' ">true</UseMonoRuntime>

See: 0db0be1#diff-628edd03fba0cf01ff4a78cdc5386ce2b760725ac4a25589cf190ad88d5e5ac4L25-L26

And then undo the changes to $(_AndroidRuntime).

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

We can ignore the test failures; I've been slowly trying to fix flaky tests over time.

@jonathanpeppers jonathanpeppers merged commit bb6a58e into main Jan 6, 2026
56 of 59 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/srozsival/use-mono-runtime-for-debug branch January 6, 2026 21:43
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants