Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[net8.0] Change the default RuntimeIdentifier. #18495

Merged
merged 7 commits into from Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions dotnet/targets/Xamarin.Shared.Sdk.Publish.targets
Expand Up @@ -10,14 +10,6 @@
<PkgPackageDir Condition="'$(PkgPackageDir)' == '' And '$(PkgPackagePath)' == ''">$(PublishDir)</PkgPackageDir>
</PropertyGroup>

<!-- Unfortunately we can't set a default runtime identifier when publishing, because by the time we know we're publishing,
it's too late to change the runtime identifier. This means that we'll have to make it mandatory to specify a runtime
identifier when publishing for a mobile platform (iOS, tvOS), because the default runtime identifier is for the simulator. -->
<Error
Text="A runtime identifier must be specified in order to publish this project."
Condition="'$(_XamarinUsingDefaultRuntimeIdentifier)' == 'true' And ('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS')"
/>

<!-- It's mandatory to specify a runtime identifier for device when publishing for a mobile platform (iOS, tvOS). -->
<Error
Text="A runtime identifier for a device architecture must be specified in order to publish this project. '$(RuntimeIdentifier)' is a simulator architecture."
Expand Down
22 changes: 18 additions & 4 deletions dotnet/targets/Xamarin.Shared.Sdk.props
Expand Up @@ -77,12 +77,26 @@

<_XamarinUsingDefaultRuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">true</_XamarinUsingDefaultRuntimeIdentifier>

<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(_PlatformName)' == 'iOS'">iossimulator-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(_PlatformName)' == 'tvOS'">tvossimulator-x64</RuntimeIdentifier>
<!-- Figure out which architecture we're running on -->
<_IsArm64Machine Condition="'$(_IsArm64Machine)' == '' And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'arm64'">true</_IsArm64Machine>
<_IsArm64Machine Condition="'$(_IsArm64Machine)' == ''">false</_IsArm64Machine>

<!-- for mobile non-publish builds we default to the simulator (and the host mac's architecture) -->
<!-- for mobile publish builds we default to the device architecture -->
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(_PlatformName)' == 'iOS' And '$(_IsPublishing)' == 'true'">ios-arm64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(_PlatformName)' == 'iOS' And '$(_IsPublishing)' != 'true' And '$(_IsArm64Machine)' == 'true'">iossimulator-arm64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(_PlatformName)' == 'iOS' And '$(_IsPublishing)' != 'true' And '$(_IsArm64Machine)' != 'true'">iossimulator-x64</RuntimeIdentifier>

<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(_PlatformName)' == 'tvOS' And '$(_IsPublishing)' == 'true'">tvos-arm64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(_PlatformName)' == 'tvOS' And '$(_IsPublishing)' != 'true' And '$(_IsArm64Machine)' == 'true'">tvossimulator-arm64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(_PlatformName)' == 'tvOS' And '$(_IsPublishing)' != 'true' And '$(_IsArm64Machine)' != 'true'">tvossimulator-x64</RuntimeIdentifier>

<!-- For debug desktop builds we default to the host architecture -->
<!-- For release desktop builds we default to universal apps in .NET 7+ -->
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(Configuration)' != 'Release' And '$(_PlatformName)' == 'macOS'">osx-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(Configuration)' != 'Release' And '$(_PlatformName)' == 'MacCatalyst'">maccatalyst-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(Configuration)' != 'Release' And '$(_PlatformName)' == 'macOS' And '$(_IsArm64Machine)' == 'true'">osx-arm64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(Configuration)' != 'Release' And '$(_PlatformName)' == 'macOS' And '$(_IsArm64Machine)' != 'true'">osx-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(Configuration)' != 'Release' And '$(_PlatformName)' == 'MacCatalyst' And '$(_IsArm64Machine)' == 'true'">maccatalyst-arm64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' And '$(Configuration)' != 'Release' And '$(_PlatformName)' == 'MacCatalyst' And '$(_IsArm64Machine)' != 'true'">maccatalyst-x64</RuntimeIdentifier>
<RuntimeIdentifiers Condition="'$(RuntimeIdentifier)' == '' And '$(Configuration)' == 'Release' And '$(_PlatformName)' == 'macOS'">osx-x64;osx-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(RuntimeIdentifier)' == '' And '$(Configuration)' == 'Release' And '$(_PlatformName)' == 'MacCatalyst'">maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers>

Expand Down
6 changes: 1 addition & 5 deletions tests/dotnet/UnitTests/PostBuildTest.cs
Expand Up @@ -160,9 +160,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";
Expand Down Expand Up @@ -198,9 +196,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.";
Expand Down
10 changes: 8 additions & 2 deletions tests/xharness/Jenkins/TestVariationsFactory.cs
Expand Up @@ -35,21 +35,27 @@ IEnumerable<TestData> 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:
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;
}

Expand Down Expand Up @@ -136,7 +142,7 @@ IEnumerable<TestData> 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":
Expand Down Expand Up @@ -176,7 +182,7 @@ IEnumerable<TestData> 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) };
Expand Down