Skip to content

Commit 5db998a

Browse files
- Improve comments and in-place documentation
- Make the condition in _WindowsDesktopFrameworkRequiresUseWpfOrUseWindowsForms specific to applicable TFM's
1 parent 9299ede commit 5db998a

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,27 @@
33
<_MicrosoftNetSdkWindowsDesktop>true</_MicrosoftNetSdkWindowsDesktop>
44
</PropertyGroup>
55

6-
<ItemGroup Condition=" '$(EnableDefaultItems)' == 'true' And '$(UseWPF)' == 'true' And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '3.0')">
6+
<PropertyGroup>
7+
<!--
8+
WindowsDesktop SDK supports WPF and WinForms on
9+
- .NET Core 3.0 and greater
10+
- .NET Framework 3.0 and greater
11+
12+
Note that on .NET Framework versions < 4.0, additional workarounds may be required to build applications
13+
using the SDK style projects. For e.g., see https://github.com/microsoft/msbuild/issues/1333
14+
15+
Irrespective of whether '$(TargetFrameworkIdentifier)' is '.NETCoreApp' or '.NETFramework',
16+
the minimum value of $(_TargetFrameworkVersionWithoutV) we will be testing for is '3.0'
17+
18+
Note:
19+
Please see https://github.com/microsoft/msbuild/issues/3212 for a discussion about the use of
20+
the private $(_TargetFrameworkVersionWithoutV) property - which will likely remain supported and
21+
is safe to use here.
22+
-->
23+
<_WindowsDesktopSdkTargetFrameworkVersionFloor>3.0</_WindowsDesktopSdkTargetFrameworkVersionFloor>
24+
</PropertyGroup>
25+
26+
<ItemGroup Condition=" '$(EnableDefaultItems)' == 'true' And '$(UseWPF)' == 'true' And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
727
<ApplicationDefinition Include="App.xaml"
828
Condition="'$(EnableDefaultApplicationDefinition)' != 'false' And Exists('$(MSBuildProjectDirectory)/App.xaml') And '$(MSBuildProjectExtension)' == '.csproj'">
929
<Generator>MSBuild:Compile</Generator>
@@ -34,15 +54,15 @@
3454
Condition="'$(EnableDefaultApplicationDefinition)' != 'false' And '$(EnableDefaultPageItems)' != 'false'" />
3555
</ItemGroup>
3656

37-
<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(UseWPF)' == 'true') And ('$(UseWindowsForms)' == 'true') And ('$(TargetFrameworkIdentifier)' == '.NETCoreApp') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '3.0')">
57+
<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(UseWPF)' == 'true') And ('$(UseWindowsForms)' == 'true') And ('$(TargetFrameworkIdentifier)' == '.NETCoreApp') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
3858
<FrameworkReference Include="Microsoft.WindowsDesktop.App" IsImplicitlyDefined="true" />
3959
</ItemGroup>
4060

41-
<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(UseWPF)' == 'true') And ('$(UseWindowsForms)' != 'true') And ('$(TargetFrameworkIdentifier)' == '.NETCoreApp') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '3.0')">
61+
<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(UseWPF)' == 'true') And ('$(UseWindowsForms)' != 'true') And ('$(TargetFrameworkIdentifier)' == '.NETCoreApp') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
4262
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WPF" IsImplicitlyDefined="true" />
4363
</ItemGroup>
4464

45-
<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(UseWPF)' != 'true') And ('$(UseWindowsForms)' == 'true') And ('$(TargetFrameworkIdentifier)' == '.NETCoreApp') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '3.0')">
65+
<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(UseWPF)' != 'true') And ('$(UseWindowsForms)' == 'true') And ('$(TargetFrameworkIdentifier)' == '.NETCoreApp') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
4666
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms" IsImplicitlyDefined="true" />
4767
</ItemGroup>
4868

@@ -66,12 +86,10 @@
6686
UIAutomationClient, UIAutomationClientSideProviders, UIAutomationProvider, UIAutomationTypes
6787
System.Windows.Controls.Ribbon
6888
69-
Note:
70-
Please see https://github.com/microsoft/msbuild/issues/3212 for a discussion about the use of
71-
the private $(_TargetFrameworkVersionWithoutV) property - which will likely remain supported and
72-
is safe to use here.
89+
Note:
90+
These are WPF specific version lower-bounds. Do not use $(_WindowsDesktopSdkTargetFrameworkVersionFloor) in place of '3.0' below.
7391
-->
74-
<ItemGroup Condition="('$(TargetFrameworkIdentifier)' == '.NETFramework') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '3.0')">
92+
<ItemGroup Condition="('$(TargetFrameworkIdentifier)' == '.NETFramework') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
7593
<_WpfCommonNetFxReference Include="WindowsBase" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '3.0'" />
7694
<_WpfCommonNetFxReference Include="PresentationCore" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '3.0'" />
7795
<_WpfCommonNetFxReference Include="PresentationFramework" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '3.0'" />
@@ -87,15 +105,15 @@
87105
<_WpfCommonNetFxReference Include="System.Windows.Controls.Ribbon" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.5'" />
88106
</ItemGroup>
89107

90-
<ItemGroup Condition=" ('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(TargetFrameworkIdentifier)' == '.NETFramework') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '3.0') And ('$(UseWPF)' == 'true') ">
108+
<ItemGroup Condition=" ('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(TargetFrameworkIdentifier)' == '.NETFramework') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)') And ('$(UseWPF)' == 'true') ">
91109
<_SDKImplicitReference Include="@(_WpfCommonNetFxReference)" />
92110
</ItemGroup>
93111

94-
<ItemGroup Condition=" ('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(TargetFrameworkIdentifier)' == '.NETFramework') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '3.0') And ('$(UseWindowsForms)' == 'true') ">
112+
<ItemGroup Condition=" ('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(TargetFrameworkIdentifier)' == '.NETFramework') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)') And ('$(UseWindowsForms)' == 'true') ">
95113
<_SDKImplicitReference Include="System.Windows.Forms"/>
96114
</ItemGroup>
97115

98-
<ItemGroup Condition=" ('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(TargetFrameworkIdentifier)' == '.NETFramework') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '3.0') And ('$(UseWindowsForms)' == 'true') And ('$(UseWPF)' == 'true') ">
116+
<ItemGroup Condition=" ('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(TargetFrameworkIdentifier)' == '.NETFramework') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)') And ('$(UseWindowsForms)' == 'true') And ('$(UseWPF)' == 'true') ">
99117
<_SDKImplicitReference Include="WindowsFormsIntegration"/>
100118
</ItemGroup>
101119
</Project>

packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project>
22
<Import Project="Microsoft.WinFX.targets" />
3-
4-
<!-- $(TargetFrameworkIdentifier) can be '.NETCoreApp' or '.NETFramework' -->
5-
<ItemGroup Condition=" ('$(EnableDefaultItems)' == 'true') And ('$(UseWPF)' == 'true') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '3.0')">
3+
4+
<ItemGroup Condition=" ('$(EnableDefaultItems)' == 'true') And ('$(UseWPF)' == 'true') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
65

76
<!-- In the WindowsDesktop .props, we globbed all .xaml files as Page items. If any of those files are included
87
as Resource, Content, or None items, then remove them from the Page items. -->
@@ -16,7 +15,7 @@
1615
<Target Name="CheckForDuplicatePageItems"
1716
BeforeTargets="_CheckForInvalidConfigurationAndPlatform;CoreCompile"
1817
DependsOnTargets="CheckForDuplicateItems"
19-
Condition="('$(UseWPF)' == 'true') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '3.0')">
18+
Condition="('$(UseWPF)' == 'true') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
2019

2120
<CheckForDuplicateItems
2221
Items="@(Page)"
@@ -44,8 +43,9 @@
4443
-->
4544
<Target Name="_WindowsDesktopFrameworkRequiresUseWpfOrUseWindowsForms"
4645
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
47-
Condition="'$(UseWpf)' != 'true' And '$(UseWindowsForms)' != 'true'">
48-
<NetSdkWarning ResourceName="WindowsDesktopFrameworkRequiresUseWpfOrUseWindowsForms" />
46+
Condition="'$(_TargetFrameworkVersionWithoutV)' != '' And '$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)'">
47+
<NetSdkWarning ResourceName="WindowsDesktopFrameworkRequiresUseWpfOrUseWindowsForms"
48+
Condition="'$(UseWpf)' != 'true' And '$(UseWindowsForms)' != 'true'"/>
4949
</Target>
5050

5151
<!--
@@ -56,7 +56,7 @@
5656
-->
5757
<Target Name="_WindowsDesktopFrameworkRequiresVersion30"
5858
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
59-
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(_TargetFrameworkVersionWithoutV)' != '' And '$(_TargetFrameworkVersionWithoutV)' &lt; '3.0'">
59+
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(_TargetFrameworkVersionWithoutV)' != '' And '$(_TargetFrameworkVersionWithoutV)' &lt; '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)'">
6060
<NetSdkWarning ResourceName="WindowsDesktopFrameworkRequiresVersion30" />
6161
</Target>
6262
</Project>

0 commit comments

Comments
 (0)