Skip to content

Commit 09974a4

Browse files
committed
Update 'TargetPlatformVersion' parsing
1 parent a8392d7 commit 09974a4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ Copyright (c) .NET Foundation. All rights reserved.
6565
<PropertyGroup Condition="'$(TargetFramework)' != '' and ('$(TargetPlatformIdentifier)' == '' or '$(TargetPlatformVersion)' == '')">
6666
<TargetPlatformIdentifier Condition="'$(TargetPlatformIdentifier)' == ''">$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
6767
<TargetPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'Windows'" >$([MSBuild]::GetTargetPlatformVersion('$(TargetFramework)', 4))</TargetPlatformVersion>
68+
69+
<!--
70+
In order to support multi-targeting between CsWinRT 2.x and CsWinRT 3.0, we use the revision number of the Windows SDK to indicate the CsWinRT version.
71+
Specifically, '.0' indicates CsWinRT 2.x, and '.1' indicates CsWinRT 3.0. Because we want the rest of the tooling to still always see the '.0' version
72+
for the Windows SDK (as the '.1' only has meaning for the .NET SDK), here we check if we're using CsWinRT 3.0, and if so we store that result and then
73+
immediately reset the revision number back to '.0' so that the rest of the tooling continues to see the same version as before.
74+
-->
75+
<_TargetPlatformVersionUsesCsWinRT3>false</_TargetPlatformVersionUsesCsWinRT3>
76+
<_TargetPlatformVersionUsesCsWinRT3 Condition="'$(TargetPlatformIdentifier)' == 'Windows' and $([System.Version]::Parse('$(TargetPlatformVersion)').Revision) == 1">true</_TargetPlatformVersionUsesCsWinRT3>
77+
<TargetPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'Windows' and '$(_TargetPlatformVersionUsesCsWinRT3)' == 'true'" >$([MSBuild]::GetTargetPlatformVersion('$(TargetFramework)', 3)).0</TargetPlatformVersion>
78+
6879
<TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == '' or ('$(TargetPlatformIdentifier)' == 'Windows' and !$([MSBuild]::VersionGreaterThanOrEquals($(TargetPlatformVersion), 10.0)))" >$([MSBuild]::GetTargetPlatformVersion('$(TargetFramework)', 2))</TargetPlatformVersion>
6980
<TargetPlatformVersion Condition="$([MSBuild]::VersionEquals($(TargetPlatformVersion), 0.0))" ></TargetPlatformVersion>
7081
<!-- Normalize casing of windows to Windows -->

0 commit comments

Comments
 (0)