Skip to content

Commit

Permalink
Fix version comparison and use built-in property
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kzu authored Apr 8, 2021
1 parent 97caa63 commit 225ce15
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/SmallSharp/SmallSharp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<UsingTask AssemblyFile="SmallSharp.dll" TaskName="MonitorActiveDocument" Condition="'$(BuildingInsideVisualStudio)' == 'true'" />

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

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

0 comments on commit 225ce15

Please sign in to comment.