Skip to content

Commit 7d04764

Browse files
[coreclr] projects with UseMonoRuntime=false successfully build (#9754)
This is a step towards Android projects using `UseMonoRuntime=false` successfully: 1. Create new packs such as `Microsoft.Android.Runtime.CoreCLR.[api].[rid]` 2. Ensure a project *builds* with `UseMonoRuntime=false` in both `Debug` and `Release` configurations. 3. The project will not be able to run successfully yet. (Significant work required for no. 3)
1 parent fe43417 commit 7d04764

File tree

6 files changed

+66
-2
lines changed

6 files changed

+66
-2
lines changed

Configuration.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,5 +216,6 @@
216216
<ItemGroup>
217217
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="Mono" />
218218
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="NativeAOT" />
219+
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="CoreCLR" />
219220
</ItemGroup>
220221
</Project>

build-tools/create-packs/Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
<Target Name="_CreateItemGroups">
5858
<ItemGroup>
59-
<_AndroidRuntimeNames Include="Mono;NativeAOT" />
59+
<_AndroidRuntimeNames Include="@(AndroidAbiAndRuntimeFlavor->'%(AndroidRuntime)'->Distinct())" />
6060
<_AndroidRIDs Include="android-arm;android-arm64;android-x86;android-x64" Runtime="%(_AndroidRuntimeNames.Identity)" />
6161
</ItemGroup>
6262
</Target>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!--
2+
***********************************************************************************************
3+
Microsoft.Android.Sdk.CoreCLR.targets
4+
5+
This file contains the CoreCLR-specific MSBuild logic for .NET for Android.
6+
***********************************************************************************************
7+
-->
8+
<Project>
9+
10+
<!-- Default property values for CoreCLR -->
11+
<PropertyGroup>
12+
<_AndroidRuntimePackRuntime>CoreCLR</_AndroidRuntimePackRuntime>
13+
</PropertyGroup>
14+
15+
</Project>

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<Import Project="Microsoft.Android.Sdk.DefaultProperties.targets" />
2828
<Import Project="$(MSBuildThisFileDirectory)..\tools\Xamarin.Android.Common.Debugging.props"
2929
Condition="Exists('$(MSBuildThisFileDirectory)..\tools\Xamarin.Android.Common.Debugging.props') And '$(DesignTimeBuild)' != 'true' "/>
30-
<Import Project="Microsoft.Android.Sdk.NativeAOT.targets" Condition=" '$(_AndroidRuntime)' == 'NativeAOT' And '$(DesignTimeBuild)' != 'true' " />
30+
<Import Project="Microsoft.Android.Sdk.CoreCLR.targets" Condition=" '$(_AndroidRuntime)' == 'CoreCLR' " />
31+
<Import Project="Microsoft.Android.Sdk.NativeAOT.targets" Condition=" '$(_AndroidRuntime)' == 'NativeAOT' " />
3132

3233
</Project>

src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,22 @@
8181
"kind": "framework",
8282
"version": "@WORKLOAD_VERSION@"
8383
},
84+
"Microsoft.Android.Runtime.CoreCLR.35.android-arm": {
85+
"kind": "framework",
86+
"version": "@WORKLOAD_VERSION@"
87+
},
88+
"Microsoft.Android.Runtime.CoreCLR.35.android-arm64": {
89+
"kind": "framework",
90+
"version": "@WORKLOAD_VERSION@"
91+
},
92+
"Microsoft.Android.Runtime.CoreCLR.35.android-x86": {
93+
"kind": "framework",
94+
"version": "@WORKLOAD_VERSION@"
95+
},
96+
"Microsoft.Android.Runtime.CoreCLR.35.android-x64": {
97+
"kind": "framework",
98+
"version": "@WORKLOAD_VERSION@"
99+
},
84100
"Microsoft.Android.Runtime.NativeAOT.35.android-arm": {
85101
"kind": "framework",
86102
"version": "@WORKLOAD_VERSION@"
@@ -117,6 +133,22 @@
117133
"kind": "framework",
118134
"version": "@WORKLOAD_VERSION@"
119135
},
136+
"Microsoft.Android.Runtime.CoreCLR.36.android-arm": {
137+
"kind": "framework",
138+
"version": "@WORKLOAD_VERSION@"
139+
},
140+
"Microsoft.Android.Runtime.CoreCLR.36.android-arm64": {
141+
"kind": "framework",
142+
"version": "@WORKLOAD_VERSION@"
143+
},
144+
"Microsoft.Android.Runtime.CoreCLR.36.android-x86": {
145+
"kind": "framework",
146+
"version": "@WORKLOAD_VERSION@"
147+
},
148+
"Microsoft.Android.Runtime.CoreCLR.36.android-x64": {
149+
"kind": "framework",
150+
"version": "@WORKLOAD_VERSION@"
151+
},
120152
"Microsoft.Android.Runtime.NativeAOT.36.android-arm": {
121153
"kind": "framework",
122154
"version": "@WORKLOAD_VERSION@"

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,21 @@ public void BuildBasicApplication ([Values (true, false)] bool isRelease, [Value
105105
}
106106
}
107107

108+
[Test]
109+
public void BasicApplicationOtherRuntime ([Values (true, false)] bool isRelease)
110+
{
111+
var proj = new XamarinAndroidApplicationProject {
112+
IsRelease = isRelease,
113+
// Add locally downloaded CoreCLR packs
114+
ExtraNuGetConfigSources = {
115+
Path.Combine (XABuildPaths.BuildOutputDirectory, "nuget-unsigned"),
116+
}
117+
};
118+
proj.SetProperty ("UseMonoRuntime", "false"); // Enables CoreCLR
119+
var b = CreateApkBuilder ();
120+
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
121+
}
122+
108123
[Test]
109124
public void NativeAOT ()
110125
{

0 commit comments

Comments
 (0)