Skip to content

Commit 12c6916

Browse files
Define _WindowsDesktopTargetFrameworkVersion as an Item to ensure it is evaluated after properties (like _TargetFrameworkVersionWithoutV) are defined
1 parent 5a37600 commit 12c6916

File tree

2 files changed

+39
-32
lines changed

2 files changed

+39
-32
lines changed

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

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
<Project>
22
<PropertyGroup>
33
<_MicrosoftNetSdkWindowsDesktop>true</_MicrosoftNetSdkWindowsDesktop>
4-
5-
<_InvalidTargetFrameworkVersion>0.0</_InvalidTargetFrameworkVersion>
6-
<_TargetFrameworkVersionValue Condition="'$(_TargetFrameworkVersionValue)' == ''">$([MSBuild]::ValueOrDefault($(_TargetFrameworkVersionWithoutV), $(_InvalidTargetFrameworkVersion)))</_TargetFrameworkVersionValue>
7-
4+
85
<EnableDefaultPageItems Condition="'$(EnableDefaultPageItems)' == ''">true</EnableDefaultPageItems>
96
<EnableDefaultApplicationDefinition Condition="'$(EnableDefaultApplicationDefinition)' == ''">true</EnableDefaultApplicationDefinition>
107
</PropertyGroup>
8+
9+
<PropertyGroup>
10+
<_InvalidTargetFrameworkVersion>0.0</_InvalidTargetFrameworkVersion>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<_WindowsDesktopTargetFrameworkVersion Remove="@(_WindowsDesktopTargetFrameworkVersion)" />
15+
<_WindowsDesktopTargetFrameworkVersion Include="$([MSBuild]::ValueOrDefault($(_TargetFrameworkVersionWithoutV), $(_InvalidTargetFrameworkVersion)))" />
16+
</ItemGroup>
17+
1118

1219
<PropertyGroup>
1320
<!--
@@ -19,19 +26,19 @@
1926
using the SDK style projects. For e.g., see https://github.com/microsoft/msbuild/issues/1333
2027
2128
Irrespective of whether '$(TargetFrameworkIdentifier)' is '.NETCoreApp' or '.NETFramework',
22-
the minimum value of $(_TargetFrameworkVersionValue) we will be testing for is '3.0'
29+
the minimum value of @(_WindowsDesktopTargetFrameworkVersion) we will be testing for is '3.0'
2330
2431
Note:
2532
Please see https://github.com/microsoft/msbuild/issues/3212 for a discussion about the use of
2633
the private $(_TargetFrameworkVersionWithoutV) property - which will likely remain supported and
27-
is safe to use here. This is used to in turn define $(_TargetFrameworkVersionValue).
34+
is safe to use here. This is used to in turn define @(_WindowsDesktopTargetFrameworkVersion).
2835
-->
2936
<_WindowsDesktopSdkTargetFrameworkVersionFloor>3.0</_WindowsDesktopSdkTargetFrameworkVersionFloor>
3037
</PropertyGroup>
3138

3239
<ItemGroup Condition=" ('$(EnableDefaultItems)' == 'true') And ('$(UseWPF)' == 'true') And
33-
('$(_TargetFrameworkVersionValue)' != '$(_InvalidTargetFrameworkVersion)') And
34-
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
40+
('@(_WindowsDesktopTargetFrameworkVersion)' != '$(_InvalidTargetFrameworkVersion)') And
41+
('@(_WindowsDesktopTargetFrameworkVersion)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
3542
<ApplicationDefinition Include="App.xaml"
3643
Condition="'$(EnableDefaultApplicationDefinition)' != 'false' And Exists('$(MSBuildProjectDirectory)/App.xaml') And '$(MSBuildProjectExtension)' == '.csproj'">
3744
<Generator>MSBuild:Compile</Generator>
@@ -65,8 +72,8 @@
6572

6673
<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And
6774
('$(TargetFrameworkIdentifier)' == '.NETCoreApp') And
68-
('$(_TargetFrameworkVersionValue)' != '$(_InvalidTargetFrameworkVersion)') And
69-
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
75+
('@(_WindowsDesktopTargetFrameworkVersion)' != '$(_InvalidTargetFrameworkVersion)') And
76+
('@(_WindowsDesktopTargetFrameworkVersion)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
7077

7178
<FrameworkReference Include="Microsoft.WindowsDesktop.App" IsImplicitlyDefined="true"
7279
Condition="('$(UseWPF)' == 'true') And ('$(UseWindowsForms)' == 'true')"/>
@@ -101,35 +108,35 @@
101108
102109
-->
103110
<ItemGroup Condition="('$(TargetFrameworkIdentifier)' == '.NETFramework') And
104-
('$(_TargetFrameworkVersionValue)' != '$(_InvalidTargetFrameworkVersion)') And
105-
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
111+
('@(_WindowsDesktopTargetFrameworkVersion)' != '$(_InvalidTargetFrameworkVersion)') And
112+
('@(_WindowsDesktopTargetFrameworkVersion)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
106113

107114
<!--
108-
The following 3 _WpfCommonNetFxReference items normally require Condition="'$(_TargetFrameworkVersionValue)' >= '3.0'", since
115+
The following 3 _WpfCommonNetFxReference items normally require Condition="'@(_WindowsDesktopTargetFrameworkVersion)' >= '3.0'", since
109116
they are supported on .NET Framework 3.0 and above.
110117
111-
This condition is implicitly satisfied by '$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)'
118+
This condition is implicitly satisfied by '@(_WindowsDesktopTargetFrameworkVersion)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)'
112119
in the outer ItemGroup
113120
-->
114121
<_WpfCommonNetFxReference Include="WindowsBase" />
115122
<_WpfCommonNetFxReference Include="PresentationCore" />
116123
<_WpfCommonNetFxReference Include="PresentationFramework" />
117124

118-
<_WpfCommonNetFxReference Include="System.Xaml" Condition="'$(_TargetFrameworkVersionValue)' >= '4.0'">
125+
<_WpfCommonNetFxReference Include="System.Xaml" Condition="'@(_WindowsDesktopTargetFrameworkVersion)' >= '4.0'">
119126
<RequiredTargetFramework>4.0</RequiredTargetFramework>
120127
</_WpfCommonNetFxReference>
121-
<_WpfCommonNetFxReference Include="UIAutomationClient" Condition="'$(_TargetFrameworkVersionValue)' >= '4.0'" />
122-
<_WpfCommonNetFxReference Include="UIAutomationClientSideProviders" Condition="'$(_TargetFrameworkVersionValue)' >= '4.0'" />
123-
<_WpfCommonNetFxReference Include="UIAutomationProvider" Condition="'$(_TargetFrameworkVersionValue)' >= '4.0'" />
124-
<_WpfCommonNetFxReference Include="UIAutomationTypes" Condition="'$(_TargetFrameworkVersionValue)' >= '4.0'" />
128+
<_WpfCommonNetFxReference Include="UIAutomationClient" Condition="'@(_WindowsDesktopTargetFrameworkVersion)' >= '4.0'" />
129+
<_WpfCommonNetFxReference Include="UIAutomationClientSideProviders" Condition="'@(_WindowsDesktopTargetFrameworkVersion)' >= '4.0'" />
130+
<_WpfCommonNetFxReference Include="UIAutomationProvider" Condition="'@(_WindowsDesktopTargetFrameworkVersion)' >= '4.0'" />
131+
<_WpfCommonNetFxReference Include="UIAutomationTypes" Condition="'@(_WindowsDesktopTargetFrameworkVersion)' >= '4.0'" />
125132

126-
<_WpfCommonNetFxReference Include="System.Windows.Controls.Ribbon" Condition="'$(_TargetFrameworkVersionValue)' >= '4.5'" />
133+
<_WpfCommonNetFxReference Include="System.Windows.Controls.Ribbon" Condition="'@(_WindowsDesktopTargetFrameworkVersion)' >= '4.5'" />
127134
</ItemGroup>
128135

129136
<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And
130137
('$(TargetFrameworkIdentifier)' == '.NETFramework') And
131-
('$(_TargetFrameworkVersionValue)' != '$(_InvalidTargetFrameworkVersion)') And
132-
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
138+
('@(_WindowsDesktopTargetFrameworkVersion)' != '$(_InvalidTargetFrameworkVersion)') And
139+
('@(_WindowsDesktopTargetFrameworkVersion)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
133140

134141
<_SDKImplicitReference Include="@(_WpfCommonNetFxReference)"
135142
Condition="'$(UseWPF)' == 'true'"/>
@@ -161,8 +168,8 @@
161168
Detect these situations and skip updates to @(SupportedTargetFramework) etc.
162169
-->
163170
<ItemGroup Condition="('$(UseWPF)' == 'true' Or '$(UseWindowsForms)' == 'true') And
164-
('$(_TargetFrameworkVersionValue)' != '$(_InvalidTargetFrameworkVersion)') And
165-
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
171+
('@(_WindowsDesktopTargetFrameworkVersion)' != '$(_InvalidTargetFrameworkVersion)') And
172+
('@(_WindowsDesktopTargetFrameworkVersion)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
166173

167174
<!--
168175
Windows Forms and WPF are supported only on .NET Core 3.0+

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<Import Project="Microsoft.WinFX.targets" />
33

44
<ItemGroup Condition=" ('$(EnableDefaultItems)' == 'true') And ('$(UseWPF)' == 'true') And
5-
('$(_TargetFrameworkVersionValue)' != '$(_InvalidTargetFrameworkVersion)') And
6-
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
5+
('@(_WindowsDesktopTargetFrameworkVersion)' != '$(_InvalidTargetFrameworkVersion)') And
6+
('@(_WindowsDesktopTargetFrameworkVersion)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
77

88
<!-- In the WindowsDesktop .props, we globbed all .xaml files as Page items. If any of those files are included
99
as Resource, Content, or None items, then remove them from the Page items. -->
@@ -18,8 +18,8 @@
1818
BeforeTargets="_CheckForInvalidConfigurationAndPlatform;CoreCompile"
1919
DependsOnTargets="CheckForDuplicateItems"
2020
Condition="('$(UseWPF)' == 'true') And
21-
('$(_TargetFrameworkVersionValue)' != '$(_InvalidTargetFrameworkVersion)') And
22-
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
21+
('@(_WindowsDesktopTargetFrameworkVersion)' != '$(_InvalidTargetFrameworkVersion)') And
22+
('@(_WindowsDesktopTargetFrameworkVersion)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
2323

2424
<CheckForDuplicateItems
2525
Items="@(Page)"
@@ -47,8 +47,8 @@
4747
-->
4848
<Target Name="_WindowsDesktopFrameworkRequiresUseWpfOrUseWindowsForms"
4949
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
50-
Condition="('$(_TargetFrameworkVersionValue)' != '$(_InvalidTargetFrameworkVersion)') And
51-
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
50+
Condition="('@(_WindowsDesktopTargetFrameworkVersion)' != '$(_InvalidTargetFrameworkVersion)') And
51+
('@(_WindowsDesktopTargetFrameworkVersion)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
5252
<NetSdkWarning ResourceName="WindowsDesktopFrameworkRequiresUseWpfOrUseWindowsForms"
5353
Condition="'$(UseWpf)' != 'true' And '$(UseWindowsForms)' != 'true'"/>
5454
</Target>
@@ -62,8 +62,8 @@
6262
<Target Name="_WindowsDesktopFrameworkRequiresVersion30"
6363
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
6464
Condition="('$(TargetFrameworkIdentifier)' == '.NETCoreApp') And
65-
('$(_TargetFrameworkVersionValue)' != '$(_InvalidTargetFrameworkVersion)') And
66-
('$(_TargetFrameworkVersionValue)' &lt; '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
65+
('@(_WindowsDesktopTargetFrameworkVersion)' != '$(_InvalidTargetFrameworkVersion)') And
66+
('@(_WindowsDesktopTargetFrameworkVersion)' &lt; '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
6767
<NetSdkWarning ResourceName="WindowsDesktopFrameworkRequiresVersion30" />
6868
</Target>
6969
</Project>

0 commit comments

Comments
 (0)