提交 3b48663e 编写于 作者: V Vatsan Madhavan 提交者: msftbot[bot]

Fixes problems in WindowsDesktop SDK due to _TargetFrameworkVersionWithoutV...

Fixes problems in WindowsDesktop SDK due to _TargetFrameworkVersionWithoutV being undefined sometimes (#1713)

* Add _TargetFrameworkVersionValue

* Define _UndefinedTargetFrameworkVersion

* Update conditions using _TargetFrameworkVersionValue & _UndefinedTargetFrameworkVersion

* Format conditions

* Add a default value for _TargetFrameworkVersionValue in .props file, and fixup the default value in .targets file.

Fixup an incorrect comment

* Add _UndefinedTargetFrameworkVersion and _TargetFrameworkVersionValue to Pbt.targets (used for dotnet/wpf builds only)
上级 4857abcc
......@@ -92,11 +92,20 @@
Condition="'$(InternalMarkupCompilation)'=='true' And Exists('$(LocalMicrosoftWinFXTargets)') "/>
<!--
_WindowsDesktopSdkTargetFrameworkVersionFloor is defined in Microsoft.NET.WindowDesktop.props.
This needs to be defined before Microsoft.NET.Sdk.WindowsDesktop.targets is imported.
_WindowsDesktopSdkTargetFrameworkVersionFloor, _UndefinedTargetFrameworkVersion and _TargetFrameworkVersionValue are
defined in Microsoft.NET.WindowDesktop.props.
These need to be defined before Microsoft.NET.Sdk.WindowsDesktop.targets is imported.
-->
<PropertyGroup Condition="'$(InternalMarkupCompilation)'=='true' And !Exists('$(LocalMicrosoftWinFXTargets)') ">
<_WindowsDesktopSdkTargetFrameworkVersionFloor Condition="'$(_WindowsDesktopSdkTargetFrameworkVersionFloor)' == ''">3.0</_WindowsDesktopSdkTargetFrameworkVersionFloor>
<!-- Represents an undefined TFV value. -->
<_UndefinedTargetFrameworkVersion>0.0</_UndefinedTargetFrameworkVersion>
<!-- Initial/Default value set to 'undefined'. Updated in Microsoft.NET.WindowsDesktop.targets -->
<_TargetFrameworkVersionValue>$(_UndefinedTargetFrameworkVersion)</_TargetFrameworkVersionValue>
</PropertyGroup>
<Import Sdk="Microsoft.NET.Sdk.WindowsDesktop"
Project="../targets/Microsoft.NET.Sdk.WindowsDesktop.targets"
......
......@@ -15,18 +15,26 @@
using the SDK style projects. For e.g., see https://github.com/microsoft/msbuild/issues/1333
Irrespective of whether '$(TargetFrameworkIdentifier)' is '.NETCoreApp' or '.NETFramework',
the minimum value of $(_TargetFrameworkVersionWithoutV) we will be testing for is '3.0'
the minimum value of $(_TargetFrameworkVersionValue) we will be testing for is '3.0'
Note:
Please see https://github.com/microsoft/msbuild/issues/3212 for a discussion about the use of
the private $(_TargetFrameworkVersionWithoutV) property - which will likely remain supported and
is safe to use here.
-->
<_WindowsDesktopSdkTargetFrameworkVersionFloor>3.0</_WindowsDesktopSdkTargetFrameworkVersionFloor>
<!--
Represents an undefined TFV value. This will be used in comparisons of _TargetFrameworkVersionValue (defined in Microsoft.NET.WindowsDesktop.targets)
to identify when a TFV is undefined
-->
<_UndefinedTargetFrameworkVersion>0.0</_UndefinedTargetFrameworkVersion>
<!--
Initial/Default value set to 'undefined'. Updated in Microsoft.NET.WindowsDesktop.targets
-->
<_TargetFrameworkVersionValue>$(_UndefinedTargetFrameworkVersion)</_TargetFrameworkVersionValue>
</PropertyGroup>
<ItemGroup Condition=" ('$(EnableDefaultItems)' == 'true') And ('$(UseWPF)' == 'true') And
('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<ApplicationDefinition Include="App.xaml"
Condition="'$(EnableDefaultApplicationDefinition)' != 'false' And Exists('$(MSBuildProjectDirectory)/App.xaml') And '$(MSBuildProjectExtension)' == '.csproj'">
<Generator>MSBuild:Compile</Generator>
......@@ -60,8 +68,8 @@
<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And
('$(TargetFrameworkIdentifier)' == '.NETCoreApp') And
('$(_TargetFrameworkVersionWithoutV)' != '') And
('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<FrameworkReference Include="Microsoft.WindowsDesktop.App" IsImplicitlyDefined="true"
Condition="('$(UseWPF)' == 'true') And ('$(UseWindowsForms)' == 'true')"/>
......@@ -95,33 +103,36 @@
System.Windows.Controls.Ribbon
-->
<ItemGroup Condition="('$(TargetFrameworkIdentifier)' == '.NETFramework') And ('$(_TargetFrameworkVersionWithoutV)' != '') And
('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<ItemGroup Condition="('$(TargetFrameworkIdentifier)' == '.NETFramework') And
('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<!--
The following 3 _WpfCommonNetFxReference items normally require Condition="'$(_TargetFrameworkVersionWithoutV)' >= '3.0'", since
The following 3 _WpfCommonNetFxReference items normally require Condition="'$(_TargetFrameworkVersionValue)' >= '3.0'", since
they are supported on .NET Framework 3.0 and above.
This condition is implicitly satisfied by '$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)'
This condition is implicitly satisfied by '$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)'
in the outer ItemGroup
-->
<_WpfCommonNetFxReference Include="WindowsBase" />
<_WpfCommonNetFxReference Include="PresentationCore" />
<_WpfCommonNetFxReference Include="PresentationFramework" />
<_WpfCommonNetFxReference Include="System.Xaml" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.0'">
<_WpfCommonNetFxReference Include="System.Xaml" Condition="'$(_TargetFrameworkVersionValue)' >= '4.0'">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</_WpfCommonNetFxReference>
<_WpfCommonNetFxReference Include="UIAutomationClient" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.0'" />
<_WpfCommonNetFxReference Include="UIAutomationClientSideProviders" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.0'" />
<_WpfCommonNetFxReference Include="UIAutomationProvider" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.0'" />
<_WpfCommonNetFxReference Include="UIAutomationTypes" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.0'" />
<_WpfCommonNetFxReference Include="UIAutomationClient" Condition="'$(_TargetFrameworkVersionValue)' >= '4.0'" />
<_WpfCommonNetFxReference Include="UIAutomationClientSideProviders" Condition="'$(_TargetFrameworkVersionValue)' >= '4.0'" />
<_WpfCommonNetFxReference Include="UIAutomationProvider" Condition="'$(_TargetFrameworkVersionValue)' >= '4.0'" />
<_WpfCommonNetFxReference Include="UIAutomationTypes" Condition="'$(_TargetFrameworkVersionValue)' >= '4.0'" />
<_WpfCommonNetFxReference Include="System.Windows.Controls.Ribbon" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.5'" />
<_WpfCommonNetFxReference Include="System.Windows.Controls.Ribbon" Condition="'$(_TargetFrameworkVersionValue)' >= '4.5'" />
</ItemGroup>
<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And ('$(TargetFrameworkIdentifier)' == '.NETFramework') And
('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And
('$(TargetFrameworkIdentifier)' == '.NETFramework') And
('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<_SDKImplicitReference Include="@(_WpfCommonNetFxReference)"
Condition="'$(UseWPF)' == 'true'"/>
......@@ -153,7 +164,8 @@
Detect these situations and skip updates to @(SupportedTargetFramework) etc.
-->
<ItemGroup Condition="('$(UseWPF)' == 'true' Or '$(UseWindowsForms)' == 'true') And
'$(_TargetFrameworkVersionWithoutV)' != '' And '$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)'">
'$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)' And
'$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)'">
<!--
Windows Forms and WPF are supported only on .NET Core 3.0+
......
<Project>
<!--
$(TargetFrameworkVersion), $(_TargetFrameworkVersionWithoutV) etc. are defined in
Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets.
Microsoft.NET.Sdk.targets is included prior to this file by Sdk.targets, so it is safe to define _TargetFrameworkValue
here.
_TargetFrameworkValue will be used in WindowsDesktop SDK as reliable proxy for _TargetFrameworkVersionWithoutV.
_TargetFrameworkVersionWithoutV can be empty ('') or it can be a numeric value (e.g., '3.0') - which makes it hard to work with
esp. in outer builds. _TargetFrameworkValue will always be guaranteed to have a numeric value ('0.0' or a valid TFM).
_TargetFrameworkVersionValue will be used in Microsoft.NET.Sdk.WindowsDesktop.props in Item conditions. This will be valid
because Items are evaluated after Properties (see https://docs.microsoft.com/en-us/visualstudio/msbuild/comparing-properties-and-items?view=vs-2019).
Note:
Please see https://github.com/microsoft/msbuild/issues/3212 for a discussion about the use of
the private $(_TargetFrameworkVersionWithoutV) property - which will likely remain supported and
is safe to use here.
-->
<PropertyGroup>
<_TargetFrameworkVersionValue>$([MSBuild]::ValueOrDefault('$(_TargetFrameworkVersionWithoutV)', '$(_UndefinedTargetFrameworkVersion)'))</_TargetFrameworkVersionValue>
</PropertyGroup>
<Import Project="Microsoft.WinFX.targets" />
<ItemGroup Condition=" ('$(EnableDefaultItems)' == 'true') And ('$(UseWPF)' == 'true') And ('$(_TargetFrameworkVersionWithoutV)' != '') And
('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<ItemGroup Condition=" ('$(EnableDefaultItems)' == 'true') And ('$(UseWPF)' == 'true') And ('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<!-- In the WindowsDesktop .props, we globbed all .xaml files as Page items. If any of those files are included
as Resource, Content, or None items, then remove them from the Page items. -->
......@@ -16,7 +40,7 @@
<Target Name="CheckForDuplicatePageItems"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform;CoreCompile"
DependsOnTargets="CheckForDuplicateItems"
Condition="('$(UseWPF)' == 'true') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
Condition="('$(UseWPF)' == 'true') And ('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And ('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<CheckForDuplicateItems
Items="@(Page)"
......@@ -44,7 +68,7 @@
-->
<Target Name="_WindowsDesktopFrameworkRequiresUseWpfOrUseWindowsForms"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
Condition="('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
Condition="('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And ('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<NetSdkWarning ResourceName="WindowsDesktopFrameworkRequiresUseWpfOrUseWindowsForms"
Condition="'$(UseWpf)' != 'true' And '$(UseWindowsForms)' != 'true'"/>
</Target>
......@@ -58,7 +82,7 @@
<Target Name="_WindowsDesktopFrameworkRequiresVersion30"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
Condition="('$(TargetFrameworkIdentifier)' == '.NETCoreApp') And
('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' &lt; '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And ('$(_TargetFrameworkVersionValue)' &lt; '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<NetSdkWarning ResourceName="WindowsDesktopFrameworkRequiresVersion30" />
</Target>
</Project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册