Skip to content

Commit 225ce15

Browse files
authored
Fix version comparison and use built-in property
The existing code would always fail the comparison becuase it was not done numerically, but as a string, resulting in 16.10 being smaller than 16.8. We fix it by parsing the full `MSBuildVersion` as a vesion instead, and comparing it to the minimum version (16.8) also parsed as a `Version` object. Fixes #36
1 parent 97caa63 commit 225ce15

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/SmallSharp/SmallSharp.targets

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<UsingTask AssemblyFile="SmallSharp.dll" TaskName="MonitorActiveDocument" Condition="'$(BuildingInsideVisualStudio)' == 'true'" />
44

55
<PropertyGroup>
6-
<MSBuildShortVersion>$(MSBuildVersion.TrimEnd('0123456789').TrimEnd('.'))</MSBuildShortVersion>
76
<!-- Excluding top-level files so we can only set to Compile the startup/active one -->
87
<DefaultItemExcludesInProjectFolder>*$(DefaultLanguageSourceExtension)</DefaultItemExcludesInProjectFolder>
98
<UserProjectNamespace>
@@ -22,7 +21,7 @@
2221

2322
<!-- NOTE: we only require VS16.8+ when running in the IDE, since for CLI builds we just do targets stuff -->
2423
<Target Name="EnsureVisualStudio" BeforeTargets="BeforeCompile;CoreCompile"
25-
Condition="$(MSBuildShortVersion) &lt; '16.8' and '$(BuildingInsideVisualStudio)' == 'true'">
24+
Condition="$([System.Version]::Parse('16.8.0').CompareTo($([System.Version]::Parse($(MSBuildVersion))))) == 1 and '$(BuildingInsideVisualStudio)' == 'true'">
2625
<!-- Top-level programs require this, so does our source generator. -->
2726
<Error Text="SmallSharp requires Visual Studio 16.8 or greater." />
2827
</Target>

0 commit comments

Comments
 (0)