Skip to content

Commit 441dc4e

Browse files
committed
Improved HasWinUI / HasWinUI2 conditional logic
1 parent b42838d commit 441dc4e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

MultiTarget/MultiTargetIdentifiers.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@
5353

5454
<IsUno Condition="'$(IsWasm)' == 'true' OR '$(IsWpf)' == 'true' OR '$(IsGtk)' == 'true' OR '$(IsDroid)' == 'true' OR '$(IsMacOS)' == 'true' OR '$(IsiOS)' == 'true'">true</IsUno>
5555

56-
<HasWinUI Condition="'$(HasWinUI)' == '' AND ('$(IsUwp)' == 'true' OR '$(IsWinAppSdk)' == 'true' OR '$(IsUno)' == 'true')">true</HasWinUI>
5756

5857
<!--
5958
This property is only for changing the version used by Uno.
6059
Force the version to 2 for UWP and 3 for WinAppSDK.
6160
-->
62-
<WinUIMajorVersion Condition="'$(HasWinUI)' == 'true' AND '$(IsUwp)' == 'true' AND $(WinUIMajorVersion) == ''">2</WinUIMajorVersion>
63-
<WinUIMajorVersion Condition="'$(HasWinUI)' == 'true' AND '$(IsWinAppSdk)' == 'true' AND $(WinUIMajorVersion) == ''">3</WinUIMajorVersion>
61+
<WinUIMajorVersion Condition="'$(IsUwp)' == 'true'">2</WinUIMajorVersion>
62+
<WinUIMajorVersion Condition="'$(IsWinAppSdk)' == 'true'">3</WinUIMajorVersion>
63+
64+
<HasWinUI Condition="'$(HasWinUI)' == '' AND '$(WinUIMajorVersion)' == '2' AND '$(HasWinUI2)' == 'false'">false</HasWinUI>
65+
<HasWinUI Condition="'$(HasWinUI)' == '' AND ('$(IsUwp)' == 'true' OR '$(IsWinAppSdk)' == 'true' OR '$(IsUno)' == 'true')">true</HasWinUI>
6466

6567
<UseUwp Condition="'$(HasWinUI)' == 'true' AND '$(IsUwp)' == 'true' AND '$(MultiTargetPlatformIdentifier)' == 'windows'">true</UseUwp>
66-
67-
<HasWinUI2 Condition="'$(HasWinUI2)' == '' AND '$(HasWinUI)' == 'true' AND '$(WinUIMajorVersion)' == '2'">true</HasWinUI2>
6868
</PropertyGroup>
6969
</Project>

MultiTarget/PackageReferences/Uwp/Microsoft.UI.Xaml.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project>
22
<!-- Condition must be on a <When> statement in its own file for this to work in Visual Studio. https://stackoverflow.com/a/16557059 -->
33
<Choose>
4-
<When Condition="'$(HasWinUI2)' == 'true' AND '$(MultiTargetPlatformIdentifier)' != 'windows'" >
4+
<When Condition="'$(HasWinUI)' == 'true' AND '$(MultiTargetPlatformIdentifier)' != 'windows'" >
55
<ItemGroup>
66
<PackageReference Include="Microsoft.UI.Xaml" Version="2.8.6" />
77
</ItemGroup>
88
</When>
9-
<When Condition="'$(HasWinUI2)' == 'true' AND '$(MultiTargetPlatformIdentifier)' == 'windows'" >
9+
<When Condition="'$(HasWinUI)' == 'true' AND '$(MultiTargetPlatformIdentifier)' == 'windows'" >
1010
<ItemGroup>
1111
<!-- Prerelease version needed for TargetFramework support. Not needed by uap. -->
1212
<PackageReference Include="Microsoft.UI.Xaml" Version="2.8.7-prerelease.241119001" />

0 commit comments

Comments
 (0)