Skip to content

Commit f7665f3

Browse files
committed
Add 'HasWindowsUIXaml ' property
1 parent f26673e commit f7665f3

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

MultiTarget/MultiTargetIdentifiers.props

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
They can be overriden if defined in the consuming project.
77
-->
88
<Project InitialTargets="MultiTargetCompatabilityCheck">
9-
<Target Name="MultiTargetCompatabilityCheck">
10-
<!-- netstandard is not compatible with Uno platforms. -->
11-
<Error Condition="$(IsNetstandard) == 'true' AND $(IsUno) == 'true'" Text="Projects cannot MultiTarget both netstandard and Uno Platform." />
12-
</Target>
139

1410
<PropertyGroup Condition="$(IsDeployableHead) == 'true'">
1511
<!-- See https://github.com/CommunityToolkit/Labs-Windows/issues/142 -->
@@ -64,11 +60,28 @@
6460
<HasWinUI Condition="'$(HasWinUI)' == '' AND '$(WinUIMajorVersion)' == '2' AND '$(HasWinUI2)' == 'false'">false</HasWinUI>
6561
<HasWinUI Condition="'$(HasWinUI)' == '' AND ('$(IsUwp)' == 'true' OR '$(IsWinAppSdk)' == 'true' OR '$(IsUno)' == 'true')">true</HasWinUI>
6662

63+
<!-- Can be used to opt-out of the UWP XAML framework reference, if not needed -->
64+
<HasWindowsUIXaml Condition="'$(HasWindowsUIXaml)' == '' AND '$(IsUwp)' == 'true'">true</HasWindowsUIXaml>
65+
<HasWindowsUIXaml Condition="'$(HasWindowsUIXaml)' == '' AND '$(IsUwp)' != 'true'">false</HasWindowsUIXaml>
66+
6767
<!--
6868
The 'UseUwp' property tells the .NET SDK to add a framework reference for the 'Microsoft.Windows.UI.Xaml.dll' assembly, which allows
6969
.NET projects to access UWP XAML types. This is orthogonal to whether WinUI is being used or not. As such, we always set this for
7070
UWP projects that have 'windows' as identifier (i.e. they are not 'UAP' projects, which is legacy UWP), regardless of WinUI.
7171
-->
72-
<UseUwp Condition="'$(IsUwp)' == 'true' AND '$(MultiTargetPlatformIdentifier)' == 'windows'">true</UseUwp>
72+
<UseUwp Condition="'$(IsUwp)' == 'true' AND '$(MultiTargetPlatformIdentifier)' == 'windows' AND '$(HasWindowsUIXaml)' == 'true'">true</UseUwp>
7373
</PropertyGroup>
74+
75+
<Target Name="MultiTargetCompatabilityCheck">
76+
77+
<!-- .NET Standard is not compatible with Uno platforms -->
78+
<Error Condition="'$(IsNetstandard)' == 'true' AND '$(IsUno)' == 'true'" Text="Projects cannot MultiTarget both netstandard and Uno Platform." />
79+
80+
<!--
81+
UWP XAML can only be enabled for UWP projects. No need to warn for UWP XAML
82+
being disabled when WinUI 2 is used, as that will already fail to build.
83+
-->
84+
<Error Condition="'$(HasWindowsUIXaml)' == 'true' AND '$(IsUwp)' != 'true'" Text="Projects cannot reference Windows UI XAML if they're not targeting UWP." />
85+
<Error Condition="'$(HasWindowsUIXaml)' == 'false' AND '$(IsUwp)' == 'true' AND '$(MultiTargetPlatformIdentifier)' != 'windows'" Text="Projects cannot disabl Windows UI XAML if they're targeting legacy UWP." />
86+
</Target>
7487
</Project>

0 commit comments

Comments
 (0)