Skip to content

Commit

Permalink
[dotnet] Fix building universal apps using NativeAOT when the default…
Browse files Browse the repository at this point in the history
… RuntimeIdentifiers value is set. Fixes #19391.

We need to set "UseCurrentRuntimeIdentifier=false", we must only set it for
the outer build for universal builds - when `RuntimeIdentifiers` is set - but
that means we can only do it *after* we set any default value for
`RuntimeIdentifiers`.

Fixes #19391 (comment).
  • Loading branch information
rolfbjarne committed Oct 10, 2024
1 parent d293744 commit 4616142
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions dotnet/targets/Xamarin.Shared.Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@
<!-- Tell .NET to skip sanity checks that trigger too eagerly for builds with multiple RuntimeIdentifiers -->
<AllowPublishAotWithoutRuntimeIdentifier Condition="'$(AllowPublishAotWithoutRuntimeIdentifier)' == '' And '$(_UseNativeAot)' == 'true'">true</AllowPublishAotWithoutRuntimeIdentifier>
<AllowSelfContainedWithoutRuntimeIdentifier Condition="'$(AllowSelfContainedWithoutRuntimeIdentifier)' == ''">true</AllowSelfContainedWithoutRuntimeIdentifier>

<!-- Prevent .NET from resolving runtime identifier for NativeAOT builds when building universal apps. -->
<UseCurrentRuntimeIdentifier Condition="'$(_UseNativeAot)' == 'true' And '$(RuntimeIdentifiers)' != '' And '$(RuntimeIdentifier)' == ''">false</UseCurrentRuntimeIdentifier>

</PropertyGroup>

<!-- Set the default RuntimeIdentifier if not already specified. -->
Expand Down Expand Up @@ -142,6 +138,9 @@
</PropertyGroup>

<PropertyGroup>
<!-- Prevent .NET from resolving runtime identifier for NativeAOT builds when building universal apps. -->
<UseCurrentRuntimeIdentifier Condition="'$(_UseNativeAot)' == 'true' And '$(RuntimeIdentifiers)' != '' And '$(RuntimeIdentifier)' == ''">false</UseCurrentRuntimeIdentifier>

<!-- See Xamarin.Shared.Sdk.Trimming.props for an explanation why we use CustomAfterDirectoryBuildTargets to compute trimming options -->
<CustomAfterDirectoryBuildTargets>$(CustomAfterDirectoryBuildTargets);$(MSBuildThisFileDirectory)Xamarin.Shared.Sdk.Trimming.props</CustomAfterDirectoryBuildTargets>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,7 @@ public void BuildMyNativeAotAppWithTrimAnalysisWarning (ApplePlatform platform,
[TestCase (ApplePlatform.MacOSX, "osx-x64", "Release")]
[TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64", "Debug")]
[TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64", "Release")]
[TestCase (ApplePlatform.MacOSX, "", "Release")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64", "Debug")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64", "Release")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64", "Debug")]
Expand Down

0 comments on commit 4616142

Please sign in to comment.