Skip to content

Commit 9d55c75

Browse files
[ci] run MSBuild "SmokeTests" category on all runtimes (#10085)
For each "smoke test" that build an Android application project (libraries not really relevant), we run the test on all runtimes. For each test, I generally added two more test cases for NativeAOT and CoreCLR. This is a first step to ensure that we don't break CoreCLR or NativeAOT support at build time. This also discovered a bug on NativeAOT, in a project with spaces, it would fail to build: clang no such file or directory: 'Me.so' C:\Users\cloudtest\.nuget\packages\microsoft.dotnet.ilcompiler\10.0.0-preview.5.25227.101\build\Microsoft.NETCore.Native.targets(391,5): error MSB3073: The command ""clang" "obj\Release\android-arm64\native\Test Me.o" -o "bin\Release\android-arm64\native\Test Me.so" -Wl,--version-script="obj\Release\android-arm64\native\Test Me.exports" -Wl,--export-dynamic -gz=zlib -fuse-ld=lld C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libSystem.Native.a C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libSystem.Globalization.Native.a C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libSystem.IO.Compression.Native.a C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libSystem.Security.Cryptography.Native.OpenSsl.a C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libbootstrapperdll.o C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libRuntime.WorkstationGC.a C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libeventpipe-disabled.a C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libstandalonegc-disabled.a C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libaotminipal.a C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libstdc++compat.a C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libbrotlienc.a C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libbrotlidec.a C:\Users\cloudtest\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\10.0.0-preview.5.25227.101/runtimes/linux-bionic-arm64/\native\libbrotlicommon.a --target=aarch64-linux-android21 -g -Wl,-rpath,"$ORIGIN" -Wl,--build-id=sha1 -Wl,--as-needed -Wl,-e,0x0 -pthread -ldl -lz -llog -lm -shared -Wl,-z,relro -Wl,-z,now -Wl,--eh-frame-hdr -Wl,-z,max-page-size=16384 -Wl,-soname,libTest Me.so -Wl,--discard-all -Wl,--gc-sections -Wl,-T,"obj\Release\android-arm64\native\sections.ld"" exited with code 1. The fix was to quote `@(LinkerArg)`: <LinkerArg Include="&quot;-Wl,-soname,lib$(TargetName)$(NativeBinaryExt)&quot;" />
1 parent a8a573c commit 9d55c75

File tree

6 files changed

+128
-22
lines changed

6 files changed

+128
-22
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
9090
</PropertyGroup>
9191
<ItemGroup>
9292
<!-- Android needs a proper soname property or it will refuse to load the library -->
93-
<LinkerArg Include="-Wl,-soname,lib$(TargetName)$(NativeBinaryExt)" />
93+
<LinkerArg Include="&quot;-Wl,-soname,lib$(TargetName)$(NativeBinaryExt)&quot;" />
9494
<!-- Required for [UnmanagedCallersOnly] to work inside this assembly -->
9595
<UnmanagedEntryPointsAssembly Include="Microsoft.Android.Runtime.NativeAOT" />
9696
<!-- Give ILLink's output to ILC -->

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using NUnit.Framework;
33
using System.IO;
44
using System.Text;
5+
using Xamarin.Android.Tasks;
56
using Xamarin.ProjectTools;
67

78
namespace Xamarin.Android.Build.Tests
@@ -35,7 +36,11 @@ public void BuildLibraryWithAssetPack ([Values (true, false)] bool isRelease)
3536

3637
[Test]
3738
[Category ("SmokeTests")]
38-
public void BuildApplicationWithAssetPackThatHasInvalidName ([Values (true, false)] bool isRelease)
39+
[TestCase (false, AndroidRuntime.MonoVM)]
40+
[TestCase (true, AndroidRuntime.MonoVM)]
41+
[TestCase (true, AndroidRuntime.CoreCLR)]
42+
[TestCase (true, AndroidRuntime.NativeAOT)]
43+
public void BuildApplicationWithAssetPackThatHasInvalidName (bool isRelease, AndroidRuntime runtime)
3944
{
4045
var path = Path.Combine ("temp", TestName);
4146
var app = new XamarinAndroidApplicationProject {
@@ -48,6 +53,7 @@ public void BuildApplicationWithAssetPackThatHasInvalidName ([Values (true, fals
4853
},
4954
}
5055
};
56+
app.SetRuntime (runtime);
5157
app.SetProperty ("AndroidPackageFormat", "aab");
5258
using (var builder = CreateApkBuilder (Path.Combine (path, app.ProjectName))) {
5359
builder.ThrowOnBuildFailure = false;
@@ -59,7 +65,11 @@ public void BuildApplicationWithAssetPackThatHasInvalidName ([Values (true, fals
5965

6066
[Test]
6167
[Category ("SmokeTests")]
62-
public void BuildApplicationWithAssetPackOutsideProjectDirectory ([Values (true, false)] bool isRelease)
68+
[TestCase (false, AndroidRuntime.MonoVM)]
69+
[TestCase (true, AndroidRuntime.MonoVM)]
70+
[TestCase (true, AndroidRuntime.CoreCLR)]
71+
[TestCase (true, AndroidRuntime.NativeAOT)]
72+
public void BuildApplicationWithAssetPackOutsideProjectDirectory (bool isRelease, AndroidRuntime runtime)
6373
{
6474
var path = Path.Combine ("temp", TestName);
6575
var app = new XamarinAndroidApplicationProject {
@@ -83,6 +93,7 @@ public void BuildApplicationWithAssetPackOutsideProjectDirectory ([Values (true,
8393
},
8494
}
8595
};
96+
app.SetRuntime (runtime);
8697
app.SetProperty ("AndroidPackageFormat", "aab");
8798
using (var appBuilder = CreateApkBuilder (Path.Combine (path, app.ProjectName))) {
8899
Assert.IsTrue (appBuilder.Build (app), $"{app.ProjectName} should succeed");
@@ -104,7 +115,11 @@ public void BuildApplicationWithAssetPackOutsideProjectDirectory ([Values (true,
104115

105116
[Test]
106117
[Category ("SmokeTests")]
107-
public void BuildApplicationWithAssetPackOverrides ([Values (true, false)] bool isRelease)
118+
[TestCase (false, AndroidRuntime.MonoVM)]
119+
[TestCase (true, AndroidRuntime.MonoVM)]
120+
[TestCase (true, AndroidRuntime.CoreCLR)]
121+
[TestCase (true, AndroidRuntime.NativeAOT)]
122+
public void BuildApplicationWithAssetPackOverrides (bool isRelease, AndroidRuntime runtime)
108123
{
109124
var path = Path.Combine ("temp", TestName);
110125
var app = new XamarinAndroidApplicationProject {
@@ -123,6 +138,7 @@ public void BuildApplicationWithAssetPackOverrides ([Values (true, false)] bool
123138
},
124139
}
125140
};
141+
app.SetRuntime (runtime);
126142
app.SetProperty ("AndroidPackageFormat", "aab");
127143
using (var appBuilder = CreateApkBuilder (Path.Combine (path, app.ProjectName))) {
128144
Assert.IsTrue (appBuilder.Build (app), $"{app.ProjectName} should succeed");
@@ -142,7 +158,12 @@ public void BuildApplicationWithAssetPackOverrides ([Values (true, false)] bool
142158

143159
[Test]
144160
[Category ("SmokeTests")]
145-
public void BuildApplicationWithAssetPack ([Values (true, false)] bool isRelease) {
161+
[TestCase (false, AndroidRuntime.MonoVM)]
162+
[TestCase (true, AndroidRuntime.MonoVM)]
163+
[TestCase (true, AndroidRuntime.CoreCLR)]
164+
[TestCase (true, AndroidRuntime.NativeAOT)]
165+
public void BuildApplicationWithAssetPack (bool isRelease, AndroidRuntime runtime)
166+
{
146167
var path = Path.Combine ("temp", TestName);
147168
var asset3 = new AndroidItem.AndroidAsset ("Assets\\asset3.txt") {
148169
TextContent = () => "Asset3",
@@ -175,6 +196,7 @@ public void BuildApplicationWithAssetPack ([Values (true, false)] bool isRelease
175196
},
176197
}
177198
};
199+
app.SetRuntime (runtime);
178200
app.SetProperty ("AndroidPackageFormat", "aab");
179201
using (var appBuilder = CreateApkBuilder (Path.Combine (path, app.ProjectName))) {
180202
Assert.IsTrue (appBuilder.Build (app), $"{app.ProjectName} should succeed");

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Xml.Linq;
66
using Microsoft.Build.Framework;
77
using NUnit.Framework;
8+
using Xamarin.Android.Tasks;
89
using Xamarin.ProjectTools;
910

1011
namespace Xamarin.Android.Build.Tests
@@ -17,96 +18,126 @@ public partial class BuildTest : BaseTest
1718
/* isRelease */ false,
1819
/* aot */ false,
1920
/* usesAssemblyStore */ false,
21+
/* runtime */ AndroidRuntime.MonoVM,
2022
},
2123
new object [] {
2224
/* runtimeIdentifiers */ "android-arm",
2325
/* isRelease */ false,
2426
/* aot */ false,
2527
/* usesAssemblyStore */ true,
28+
/* runtime */ AndroidRuntime.MonoVM,
2629
},
2730
new object [] {
2831
/* runtimeIdentifiers */ "android-arm64",
2932
/* isRelease */ false,
3033
/* aot */ false,
3134
/* usesAssemblyStore */ false,
35+
/* runtime */ AndroidRuntime.MonoVM,
3236
},
3337
new object [] {
3438
/* runtimeIdentifiers */ "android-x86",
3539
/* isRelease */ false,
3640
/* aot */ false,
3741
/* usesAssemblyStore */ false,
42+
/* runtime */ AndroidRuntime.MonoVM,
3843
},
3944
new object [] {
4045
/* runtimeIdentifiers */ "android-x64",
4146
/* isRelease */ false,
4247
/* aot */ false,
4348
/* usesAssemblyStore */ false,
49+
/* runtime */ AndroidRuntime.MonoVM,
4450
},
4551
new object [] {
4652
/* runtimeIdentifiers */ "android-arm",
4753
/* isRelease */ true,
4854
/* aot */ false,
4955
/* usesAssemblyStore */ false,
56+
/* runtime */ AndroidRuntime.MonoVM,
5057
},
5158
new object [] {
5259
/* runtimeIdentifiers */ "android-arm",
5360
/* isRelease */ true,
5461
/* aot */ false,
5562
/* usesAssemblyStore */ true,
63+
/* runtime */ AndroidRuntime.MonoVM,
5664
},
5765
new object [] {
5866
/* runtimeIdentifiers */ "android-arm",
5967
/* isRelease */ true,
6068
/* aot */ true,
6169
/* usesAssemblyStore */ false,
70+
/* runtime */ AndroidRuntime.MonoVM,
6271
},
6372
new object [] {
6473
/* runtimeIdentifiers */ "android-arm",
6574
/* isRelease */ true,
6675
/* aot */ true,
6776
/* usesAssemblyStore */ true,
77+
/* runtime */ AndroidRuntime.MonoVM,
6878
},
6979
new object [] {
7080
/* runtimeIdentifiers */ "android-arm64",
7181
/* isRelease */ true,
7282
/* aot */ false,
7383
/* usesAssemblyStore */ false,
84+
/* runtime */ AndroidRuntime.MonoVM,
7485
},
7586
new object [] {
7687
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64",
7788
/* isRelease */ false,
7889
/* aot */ false,
7990
/* usesAssemblyStore */ false,
91+
/* runtime */ AndroidRuntime.MonoVM,
8092
},
8193
new object [] {
8294
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64",
8395
/* isRelease */ false,
8496
/* aot */ false,
8597
/* usesAssemblyStore */ true,
98+
/* runtime */ AndroidRuntime.MonoVM,
8699
},
87100
new object [] {
88101
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86",
89102
/* isRelease */ true,
90103
/* aot */ false,
91104
/* usesAssemblyStore */ false,
105+
/* runtime */ AndroidRuntime.MonoVM,
92106
},
93107
new object [] {
94108
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64",
95109
/* isRelease */ true,
96110
/* aot */ false,
97111
/* usesAssemblyStore */ false,
112+
/* runtime */ AndroidRuntime.MonoVM,
98113
},
99114
new object [] {
100115
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64",
101116
/* isRelease */ true,
102117
/* aot */ false,
103118
/* usesAssemblyStore */ true,
119+
/* runtime */ AndroidRuntime.MonoVM,
104120
},
105121
new object [] {
106122
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64",
107123
/* isRelease */ true,
108124
/* aot */ true,
109125
/* usesAssemblyStore */ false,
126+
/* runtime */ AndroidRuntime.MonoVM,
127+
},
128+
new object [] {
129+
/* runtimeIdentifiers */ "android-arm64",
130+
/* isRelease */ true,
131+
/* aot */ false,
132+
/* usesAssemblyStore */ true,
133+
/* runtime */ AndroidRuntime.CoreCLR,
134+
},
135+
new object [] {
136+
/* runtimeIdentifiers */ "android-arm64",
137+
/* isRelease */ true,
138+
/* aot */ false,
139+
/* usesAssemblyStore */ false,
140+
/* runtime */ AndroidRuntime.NativeAOT,
110141
},
111142
};
112143

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

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public partial class BuildTest : BaseTest
2626
[Category ("SmokeTests")]
2727
[TestCaseSource (nameof (DotNetBuildSource))]
2828
[NonParallelizable] // On MacOS, parallel /restore causes issues
29-
public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bool usesAssemblyStore)
29+
public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bool usesAssemblyStore, AndroidRuntime runtime)
3030
{
3131
var proj = new XamarinAndroidApplicationProject {
3232
IsRelease = isRelease,
@@ -65,6 +65,7 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo
6565
},
6666
}
6767
};
68+
proj.SetRuntime (runtime);
6869
proj.MainActivity = proj.DefaultMainActivity.Replace (": Activity", ": AndroidX.AppCompat.App.AppCompatActivity")
6970
.Replace ("//${AFTER_ONCREATE}", @"button.Text = Resource.CancelButton;");
7071
proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyStore.ToString ());
@@ -104,7 +105,10 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo
104105
var builder = CreateApkBuilder ();
105106
builder.Verbosity = LoggerVerbosity.Detailed;
106107
Assert.IsTrue (builder.Build (proj), "`dotnet build` should succeed");
107-
builder.AssertHasNoWarnings ();
108+
// TODO: NativeAOT has trimmer warnings: https://github.com/dotnet/android/issues/9784
109+
if (runtime != AndroidRuntime.NativeAOT) {
110+
builder.AssertHasNoWarnings ();
111+
}
108112

109113
var outputPath = Path.Combine (Root, builder.ProjectDirectory, proj.OutputPath);
110114
var intermediateOutputPath = Path.Combine (Root, builder.ProjectDirectory, proj.IntermediateOutputPath);
@@ -126,6 +130,10 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo
126130
$"{proj.ProjectName}.runtimeconfig.json",
127131
$"{proj.ProjectName}.xml",
128132
};
133+
// NOTE: a native subdirectory exists for NativeAOT
134+
if (runtime == AndroidRuntime.NativeAOT) {
135+
expectedFiles.Add ("native");
136+
}
129137
if (isRelease) {
130138
expectedFiles.Add ($"{proj.PackageName}.aab");
131139
expectedFiles.Add ($"{proj.PackageName}-Signed.aab");
@@ -165,14 +173,23 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo
165173
var apkPath = Path.Combine (outputPath, $"{proj.PackageName}-Signed.apk");
166174
FileAssert.Exists (apkPath);
167175
var helper = new ArchiveAssemblyHelper (apkPath, usesAssemblyStore, rids);
168-
helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.dll", shouldContainEntry: expectEmbeddedAssembies);
169-
helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.pdb", shouldContainEntry: !TestEnvironment.CommercialBuildAvailable && !isRelease);
170-
helper.AssertContainsEntry ($"assemblies/Mono.Android.dll", shouldContainEntry: expectEmbeddedAssembies);
171-
helper.AssertContainsEntry ($"assemblies/es/{proj.ProjectName}.resources.dll", shouldContainEntry: expectEmbeddedAssembies);
172-
helper.AssertContainsEntry ($"assemblies/de-DE/{proj.ProjectName}.resources.dll", shouldContainEntry: expectEmbeddedAssembies);
176+
if (runtime != AndroidRuntime.NativeAOT) {
177+
helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.dll", shouldContainEntry: expectEmbeddedAssembies);
178+
helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.pdb", shouldContainEntry: !TestEnvironment.CommercialBuildAvailable && !isRelease);
179+
helper.AssertContainsEntry ($"assemblies/Mono.Android.dll", shouldContainEntry: expectEmbeddedAssembies);
180+
helper.AssertContainsEntry ($"assemblies/es/{proj.ProjectName}.resources.dll", shouldContainEntry: expectEmbeddedAssembies);
181+
helper.AssertContainsEntry ($"assemblies/de-DE/{proj.ProjectName}.resources.dll", shouldContainEntry: expectEmbeddedAssembies);
182+
}
173183
foreach (var abi in rids.Select (AndroidRidAbiHelper.RuntimeIdentifierToAbi)) {
184+
if (runtime == AndroidRuntime.MonoVM) {
185+
helper.AssertContainsEntry ($"lib/{abi}/libmonosgen-2.0.so");
186+
} else if (runtime == AndroidRuntime.CoreCLR) {
187+
helper.AssertContainsEntry ($"lib/{abi}/libcoreclr.so");
188+
} else if (runtime == AndroidRuntime.NativeAOT) {
189+
helper.AssertContainsEntry ($"lib/{abi}/lib{proj.ProjectName}.so");
190+
continue; // NOTE: NativeAOT will not include the other files below
191+
}
174192
helper.AssertContainsEntry ($"lib/{abi}/libmonodroid.so");
175-
helper.AssertContainsEntry ($"lib/{abi}/libmonosgen-2.0.so");
176193
if (rids.Length > 1) {
177194
helper.AssertContainsEntry ($"assemblies/{abi}/System.Private.CoreLib.dll", shouldContainEntry: expectEmbeddedAssembies);
178195
} else {
@@ -762,11 +779,17 @@ public void BuildAfterUpgradingNuget ()
762779

763780
[Test]
764781
[Category ("SmokeTests")]
765-
public void BuildInDesignTimeMode ([Values(false, true)] bool useManagedParser)
782+
public void BuildInDesignTimeMode (
783+
[Values (false, true)]
784+
bool useManagedParser,
785+
[Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)]
786+
AndroidRuntime runtime
787+
)
766788
{
767789
var proj = new XamarinAndroidApplicationProject () {
768790
IsRelease = true,
769791
};
792+
proj.SetRuntime (runtime);
770793
proj.SetProperty ("AndroidUseManagedDesignTimeResourceGenerator", useManagedParser.ToString ());
771794
using (var builder = CreateApkBuilder ()) {
772795
builder.Target = "UpdateAndroidResources";

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,23 @@ public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblySto
151151

152152
[Test]
153153
[Category ("SmokeTests")]
154-
[TestCase ("Test Me")]
154+
[TestCase ("Test Me", AndroidRuntime.MonoVM)]
155155
// testing characters as per https://www.compart.com/en/unicode/category/Zs
156-
[TestCase ("TestUnicodeSpace0020\u0020Me")]
157-
// TODO these break with AOT error on windows
158-
[TestCase ("TestUnicodeSpace2000\u2000Me")]
159-
[TestCase ("TestUnicodeSpace2009\u2009Me")]
160-
[TestCase ("TestUnicodeSpace2002\u2002Me")]
161-
[TestCase ("TestUnicodeSpace2007\u2007Me")]
162-
public void CheckProjectWithSpaceInNameWorks (string projectName)
156+
[TestCase ("TestUnicodeSpace0020\u0020Me", AndroidRuntime.MonoVM)]
157+
[TestCase ("TestUnicodeSpace2000\u2000Me", AndroidRuntime.MonoVM)]
158+
[TestCase ("TestUnicodeSpace2009\u2009Me", AndroidRuntime.MonoVM)]
159+
[TestCase ("TestUnicodeSpace2002\u2002Me", AndroidRuntime.MonoVM)]
160+
[TestCase ("TestUnicodeSpace2007\u2007Me", AndroidRuntime.MonoVM)]
161+
[TestCase ("TestUnicodeSpace0020\u0020Me", AndroidRuntime.CoreCLR)]
162+
[TestCase ("TestUnicodeSpace0020\u0020Me", AndroidRuntime.NativeAOT)]
163+
public void CheckProjectWithSpaceInNameWorks (string projectName, AndroidRuntime runtime)
163164
{
164165
var proj = new XamarinAndroidApplicationProject () {
165166
IsRelease = true,
166167
ProjectName = projectName,
167168
RootNamespace = "Test.Me",
168169
};
170+
proj.SetRuntime (runtime);
169171
using (var b = CreateApkBuilder ()) {
170172
Assert.IsTrue (b.Build (proj), "build failed");
171173
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Xamarin.Android.Tasks;
2+
using Xamarin.ProjectTools;
3+
4+
namespace Xamarin.Android.Build.Tests;
5+
6+
public static class ProjectExtensions
7+
{
8+
/// <summary>
9+
/// Sets the appropriate MSBuild property to use a specific .NET runtime.
10+
/// NOTE: $(EnablePreviewFeatures) ignores warning XA1040: The CoreCLR/NativeAOT runtime on Android is an experimental feature and not yet suitable for production use.
11+
/// </summary>
12+
public static void SetRuntime (this XamarinProject project, AndroidRuntime runtime)
13+
{
14+
switch (runtime) {
15+
case AndroidRuntime.CoreCLR:
16+
project.SetProperty ("UseMonoRuntime", "false");
17+
project.SetProperty ("EnablePreviewFeatures", "true");
18+
break;
19+
case AndroidRuntime.NativeAOT:
20+
project.SetProperty ("PublishAot", "true");
21+
project.SetProperty ("EnablePreviewFeatures", "true");
22+
break;
23+
default:
24+
// MonoVM or default can just use default settings
25+
break;
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)