Skip to content

Conversation

dsplaisted
Copy link
Member

@dsplaisted dsplaisted commented Oct 5, 2025

For "funky" reasons related to dotnet/msbuild#3460, the version normalization that we added in #50264 is causing exceptions to be thrown. This isn't a functional issue, the fact that the exceptions are thrown and then caught are part of how MSBuild works.

However, the additional exceptions are showing up on VS perf tests as a regression in the total number of exceptions thrown.

This PR rewrites the logic to avoid calling Version.Parse on the %(Identity), which should avoid the exceptions.

Description

Replace Version.Parse in MSBuild evaluation with regular expression to avoid first-chance exceptions in weird MSBuild evaluation modes.

Customer impact

This should not cause any visible customer impact, but it should reduce the count of exceptions thrown.

Regression

This was an exception perf counter regression over .NET 9.

Testing

Manual testing that first-chance exceptions were no longer thrown.

Risk

Low

<_NormalizedWindowsSdkSupportedTargetPlatformVersion Include="@(WindowsSdkSupportedTargetPlatformVersion)">
<NormalizedSupportedTargetPlatformVersion
Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').Split('.').Length) == 4 And
$([MSBuild]::ValueOrDefault('%(Identity)', '').Split('.').GetValue(3)) == '1'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately in the speculative-evaluation path GetValue({}) throws an IndexOutOfRangeException. Thinking of alternatives.

@dsplaisted dsplaisted merged commit 73274fb into dotnet:release/10.0.1xx Oct 10, 2025
28 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants