diff --git a/dotnet/targets/Xamarin.Shared.Sdk.Publish.targets b/dotnet/targets/Xamarin.Shared.Sdk.Publish.targets
index 07d03e18781..44d97039ff5 100644
--- a/dotnet/targets/Xamarin.Shared.Sdk.Publish.targets
+++ b/dotnet/targets/Xamarin.Shared.Sdk.Publish.targets
@@ -10,14 +10,6 @@
$(PublishDir)
-
-
-
true
- iossimulator-x64
- tvossimulator-x64
+
+ <_IsArm64Machine Condition="'$(_IsArm64Machine)' == '' And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'arm64'">true
+ <_IsArm64Machine Condition="'$(_IsArm64Machine)' == ''">false
+
+
+ ios-arm64
+ iossimulator-arm64
+ iossimulator-x64
+
+ tvos-arm64
+ tvossimulator-arm64
+ tvossimulator-x64
+
+
- osx-x64
- maccatalyst-x64
+ osx-arm64
+ osx-x64
+ maccatalyst-arm64
+ maccatalyst-x64
osx-x64;osx-arm64
maccatalyst-x64;maccatalyst-arm64
diff --git a/tests/common/Configuration.cs b/tests/common/Configuration.cs
index 53026a6fb8d..cebeb724b20 100644
--- a/tests/common/Configuration.cs
+++ b/tests/common/Configuration.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
@@ -1191,5 +1192,24 @@ static void EnsureFilestampChange ()
Thread.Sleep (1000);
}
+ // Return true if the current machine can run ARM64 binaries.
+ static bool? canRunArm64;
+ public static bool CanRunArm64 {
+ get {
+ if (!canRunArm64.HasValue) {
+ int rv = 0;
+ IntPtr size = (IntPtr) sizeof (int);
+ if (sysctlbyname ("hw.optional.arm64", ref rv, ref size, IntPtr.Zero, IntPtr.Zero) == 0) {
+ canRunArm64 = rv == 1;
+ } else {
+ canRunArm64 = false;
+ }
+ }
+ return canRunArm64.Value;
+ }
+ }
+
+ [DllImport ("libc")]
+ static extern int sysctlbyname (string name, ref int value, ref IntPtr size, IntPtr zero, IntPtr zeroAgain);
}
}
diff --git a/tests/dotnet/UnitTests/PostBuildTest.cs b/tests/dotnet/UnitTests/PostBuildTest.cs
index f436c3d29cd..93c83066d9f 100644
--- a/tests/dotnet/UnitTests/PostBuildTest.cs
+++ b/tests/dotnet/UnitTests/PostBuildTest.cs
@@ -159,9 +159,7 @@ public void PublishTest (ApplePlatform platform, string runtimeIdentifiers)
[TestCase (ApplePlatform.iOS, "iossimulator-x64")]
[TestCase (ApplePlatform.iOS, "iossimulator-x86")]
[TestCase (ApplePlatform.iOS, "iossimulator-x64;iossimulator-x64")]
- [TestCase (ApplePlatform.iOS, "")]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64")]
- [TestCase (ApplePlatform.TVOS, "")]
public void PublishFailureTest (ApplePlatform platform, string runtimeIdentifiers)
{
var project = "MySimpleApp";
@@ -197,9 +195,7 @@ public void PublishFailureTest (ApplePlatform platform, string runtimeIdentifier
var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray ();
Assert.AreEqual (1, errors.Length, "Error Count");
string expectedErrorMessage;
- if (string.IsNullOrEmpty (runtimeIdentifiers)) {
- expectedErrorMessage = $"A runtime identifier must be specified in order to publish this project.";
- } else if (runtimeIdentifiers.IndexOf (';') >= 0) {
+ if (runtimeIdentifiers.IndexOf (';') >= 0) {
expectedErrorMessage = $"A runtime identifier for a device architecture must be specified in order to publish this project. '{runtimeIdentifiers}' are simulator architectures.";
} else {
expectedErrorMessage = $"A runtime identifier for a device architecture must be specified in order to publish this project. '{runtimeIdentifiers}' is a simulator architecture.";
diff --git a/tests/dotnet/UnitTests/TestBaseClass.cs b/tests/dotnet/UnitTests/TestBaseClass.cs
index 6c7346be334..d63a4464746 100644
--- a/tests/dotnet/UnitTests/TestBaseClass.cs
+++ b/tests/dotnet/UnitTests/TestBaseClass.cs
@@ -73,15 +73,20 @@ protected string GetOutputPath (string project, string? subdir, string runtimeId
protected string GetDefaultRuntimeIdentifier (ApplePlatform platform, string configuration = "Debug")
{
+ var arch = Configuration.CanRunArm64 ? "arm64" : "x64";
switch (platform) {
case ApplePlatform.iOS:
- return "iossimulator-x64";
+ return $"iossimulator-{arch}";
case ApplePlatform.TVOS:
- return "tvossimulator-x64";
+ return $"tvossimulator-{arch}";
case ApplePlatform.MacOSX:
- return "Release".Equals (configuration, StringComparison.OrdinalIgnoreCase) ? "osx-x64;osx-arm64" : "osx-x64";
+ if ("Release".Equals (configuration, StringComparison.OrdinalIgnoreCase))
+ return "osx-x64;osx-arm64";
+ return $"osx-{arch}";
case ApplePlatform.MacCatalyst:
- return "Release".Equals (configuration, StringComparison.OrdinalIgnoreCase) ? "maccatalyst-x64;maccatalyst-arm64" : "maccatalyst-x64";
+ if ("Release".Equals (configuration, StringComparison.OrdinalIgnoreCase))
+ return "maccatalyst-x64;maccatalyst-arm64";
+ return $"maccatalyst-{arch}";
default:
throw new ArgumentOutOfRangeException ($"Unknown platform: {platform}");
}
diff --git a/tests/xharness/Jenkins/TestVariationsFactory.cs b/tests/xharness/Jenkins/TestVariationsFactory.cs
index 3ef390bdf80..9954bb966ae 100644
--- a/tests/xharness/Jenkins/TestVariationsFactory.cs
+++ b/tests/xharness/Jenkins/TestVariationsFactory.cs
@@ -35,21 +35,28 @@ IEnumerable GetTestData (RunTestTask test)
var ignore = test.TestProject.Ignore;
var mac_supports_arm64 = Harness.CanRunArm64;
var arm64_runtime_identifier = string.Empty;
+ var x64_runtime_identifier = string.Empty;
var arm64_sim_runtime_identifier = string.Empty;
+ var x64_sim_runtime_identifier = string.Empty;
switch (test.Platform) {
case TestPlatform.Mac:
arm64_runtime_identifier = "osx-arm64";
+ x64_runtime_identifier = "osx-x64";
break;
case TestPlatform.MacCatalyst:
arm64_runtime_identifier = "maccatalyst-arm64";
+ x64_runtime_identifier = "maccatalyst-x64";
break;
case TestPlatform.iOS:
case TestPlatform.iOS_Unified:
+ case TestPlatform.iOS_Unified64:
arm64_sim_runtime_identifier = "iossimulator-arm64";
+ x64_sim_runtime_identifier = "iossimulator-x64";
break;
case TestPlatform.tvOS:
arm64_sim_runtime_identifier = "tvossimulator-arm64";
+ x64_sim_runtime_identifier = "tvossimulator-x64";
break;
}
@@ -136,7 +143,7 @@ IEnumerable GetTestData (RunTestTask test)
if (test.TestProject.IsDotNetProject) {
yield return new TestData { Variation = "Debug (managed static registrar)", Registrar = "managed-static", Debug = true, Profiling = false, Ignored = ignore };
yield return new TestData { Variation = "Release (managed static registrar, all optimizations)", BundlerArguments = "--optimize:all", Registrar = "managed-static", Debug = false, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL", Ignored = ignore };
- yield return new TestData { Variation = "Release (NativeAOT)", Debug = false, PublishAot = true, Ignored = ignore, Defines = "NATIVEAOT", LinkMode = "Full" };
+ yield return new TestData { Variation = "Release (NativeAOT, x64)", Debug = false, PublishAot = true, Ignored = ignore, Defines = "NATIVEAOT", RuntimeIdentifier = x64_sim_runtime_identifier, LinkMode = "Full" };
}
break;
case "introspection":
@@ -176,7 +183,7 @@ IEnumerable GetTestData (RunTestTask test)
// yield return new TestData { Variation = "Release (NativeAOT)", Debug = false, PublishAot = true, Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Monotouch) || !jenkins.TestSelection.IsEnabled (PlatformLabel.MacCatalyst), Defines = "NATIVEAOT", LinkMode = "Full" };
yield return new TestData { Variation = "Release (NativeAOT, ARM64)", Debug = false, PublishAot = true, Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Monotouch) || !jenkins.TestSelection.IsEnabled (PlatformLabel.MacCatalyst) || !mac_supports_arm64, Defines = "NATIVEAOT", RuntimeIdentifier = arm64_runtime_identifier, LinkMode = "Full" };
- yield return new TestData { Variation = "Release (NativeAOT, x64)", Debug = false, PublishAot = true, Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Monotouch) || !jenkins.TestSelection.IsEnabled (PlatformLabel.MacCatalyst), Defines = "NATIVEAOT", LinkMode = "Full", RuntimeIdentifier = "maccatalyst-x64" };
+ yield return new TestData { Variation = "Release (NativeAOT, x64)", Debug = false, PublishAot = true, Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Monotouch) || !jenkins.TestSelection.IsEnabled (PlatformLabel.MacCatalyst), Defines = "NATIVEAOT", LinkMode = "Full", RuntimeIdentifier = x64_runtime_identifier };
}
if (test.Platform == TestPlatform.Mac) {
yield return new TestData { Variation = "Release", Debug = false, Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Monotouch) || !jenkins.TestSelection.IsEnabled (PlatformLabel.Mac) };