Skip to content

Commit 73274fb

Browse files
authored
Avoid exceptions when parsing _NormalizedWindowsSdkSupportedTargetPlatformVersion (#51134)
2 parents 1f4cb4e + 5cc6908 commit 73274fb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.WindowsSdkSupportedTargetPlatforms.props

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ Copyright (c) .NET Foundation. All rights reserved.
2424

2525
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'Windows'">
2626
<!-- Normalize the last part of TFM to .0 when ending with .1 as that indicates the use of the CsWinRT 3.0 verison. -->
27-
<_NormalizedWindowsSdkSupportedTargetPlatformVersion Include="@(WindowsSdkSupportedTargetPlatformVersion)">
28-
<NormalizedSupportedTargetPlatformVersion
29-
Condition="$([System.Version]::Parse('%(Identity)').Revision) == 1">$([System.Version]::Parse('%(Identity)').Major).$([System.Version]::Parse('%(Identity)').Minor).$([System.Version]::Parse('%(Identity)').Build).0</NormalizedSupportedTargetPlatformVersion>
30-
</_NormalizedWindowsSdkSupportedTargetPlatformVersion>
31-
<SdkSupportedTargetPlatformVersion Include="@(_NormalizedWindowsSdkSupportedTargetPlatformVersion)" />
27+
<_NormalizedWindowsSdkSupportedTargetPlatformVersion Include="@(WindowsSdkSupportedTargetPlatformVersion)">
28+
<NormalizedSupportedTargetPlatformVersion
29+
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(%(Identity), '^((\d+\.){3})1$'))"
30+
>$([System.Text.RegularExpressions.Regex]::Replace(%(Identity), '^((\d+\.){3})1$', '${1}0'))</NormalizedSupportedTargetPlatformVersion>
31+
</_NormalizedWindowsSdkSupportedTargetPlatformVersion>
32+
<SdkSupportedTargetPlatformVersion Include="@(_NormalizedWindowsSdkSupportedTargetPlatformVersion)" />
3233
</ItemGroup>
3334
</Project>

0 commit comments

Comments
 (0)