-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix MSB4086 if LangVersion is a keyword #1420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix compilation error MSB4086 if LangVersion is already set to one of the keywords such as preview, latest and latestMajor. Otherwise MSBuild complains that it cannot perform a numeric comparison.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martincostello big thanks for providing the fix!
@eerhardt could you please take a look? I want to make sure that it's the best fix possible (it looks good to me) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the fix looks good.
The only other possibility I could imagine would be using the new functionality in dotnet/msbuild#4911: $([MSBuild]::VersionLessThan(a, b))
. But I don't think there is a IsVersion
or TryParse
kind of method there. So I think what we have here is fine.
@eerhardt thank you! |
@AndreyAkinshin this bug fix and the Xamarin support make it a very good candidates to release 0.12.2 :D |
there is no end to it... dotnet/BenchmarkDotNet#1420
Fix compilation error MSB4086 with version 0.12.1 if the
LangVersion
MSBuild property is already set to one of the keywords such aspreview
,latest
andlatestMajor
(docs).Otherwise MSBuild complains that it cannot perform a numeric comparison and compilation fails.
Example compilation error from a project with
<LangVersion>latest</LangVersion>
specified in aDirectory.Build.props
file in the repository root:Open to alternative suggestions for the fix, but I've gone with just checking whether the first character of the existing value is a digit (implying it's a version number) before performing the comparison. Otherwise it assumes that the keyword resolves to a version greater than 7.3.
I'm also not sure on what the best way to add a regression test for this, again open to suggestions.
Issue appears to have been introduced by #1389 (d02c8c3).