Skip to content

Commit 72f6ce8

Browse files
authored
[dotnet] Set the default RuntimeIdentifier for publishing scenarios. (#24329)
Ref: dotnet/sdk#27253
1 parent 3a2ccef commit 72f6ce8

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

dotnet/targets/Xamarin.Shared.Sdk.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@
137137

138138
</PropertyGroup>
139139

140+
<!-- Set the default RuntimeIdentifier when publishing -->
141+
<PropertyGroup Condition="'$(PublishRuntimeIdentifier)' == ''">
142+
<PublishRuntimeIdentifier Condition="'$(_PlatformName)' == 'iOS'">ios-arm64</PublishRuntimeIdentifier>
143+
<PublishRuntimeIdentifier Condition="'$(_PlatformName)' == 'tvOS'">tvos-arm64</PublishRuntimeIdentifier>
144+
</PropertyGroup>
145+
140146
<!-- Now that we know the runtime identifier, we can determine if we're building for a simulator -->
141147
<PropertyGroup>
142148
<_SdkIsSimulator Condition="$(RuntimeIdentifier.Contains('simulator')) Or $(RuntimeIdentifiers.Contains('simulator'))">true</_SdkIsSimulator>

tests/dotnet/UnitTests/PostBuildTest.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,22 @@ public void PublishFailureTest (ApplePlatform platform, string runtimeIdentifier
233233

234234
Assert.That (pkgPath, Does.Not.Exist, "ipa/pkg creation");
235235
}
236+
237+
[TestCase (ApplePlatform.iOS, "ios-arm64")]
238+
[TestCase (ApplePlatform.TVOS, "tvos-arm64")]
239+
public void DefaultPublishRid (ApplePlatform platform, string expectedRuntimeIdentifier)
240+
{
241+
var project = "MySimpleApp";
242+
var configuration = "Release";
243+
Configuration.IgnoreIfIgnoredPlatform (platform);
244+
Configuration.AssertRuntimeIdentifiersAvailable (platform, expectedRuntimeIdentifier);
245+
246+
var project_path = GetProjectPath (project, expectedRuntimeIdentifier, platform: platform, out var appPath, configuration: configuration);
247+
Clean (project_path);
248+
249+
var properties = GetDefaultProperties ();
250+
var rv = DotNet.AssertPublish (project_path, properties);
251+
Assert.That (appPath, Does.Exist, "App existence");
252+
}
236253
}
237254
}

tests/xharness/Jenkins/TestVariationsFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ public IEnumerable<T> CreateTestVariations<T> (IEnumerable<T> tests, Func<MSBuil
229229
if (publishaot) {
230230
clone.Xml.SetProperty ("PublishAot", "true", last: false);
231231
clone.Xml.SetProperty ("_IsPublishing", "true", last: false); // quack like "dotnet publish", otherwise PublishAot=true has no effect.
232+
if (!string.IsNullOrEmpty (runtime_identifer))
233+
clone.Xml.SetProperty ("PublishRuntimeIdentifier", runtime_identifer);
232234
}
233235
if (!string.IsNullOrEmpty (test_variation)) {
234236
clone.Xml.SetProperty ("TestVariation", test_variation);

0 commit comments

Comments
 (0)