Skip to content

Commit c5037a5

Browse files
committed
Directory.Build.props: Added section to compare Visual Studio versions (including prerelease versions) to use to drive IsLegacyVisualStudioVersion property across the solution
1 parent 00d3e3e commit c5037a5

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

Directory.Build.props

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,24 @@
3131
<GitHubProject>lucenenet</GitHubProject>
3232
</PropertyGroup>
3333

34+
<PropertyGroup Label="Legacy Visual Studio Support">
35+
<VisualStudioMajorVersion>0</VisualStudioMajorVersion>
36+
<!-- Extract major version (works for preview builds too) -->
37+
<VisualStudioMajorVersion Condition="'$(VisualStudioVersion)' != ''">$([System.Version]::Parse($([System.Text.RegularExpressions.Regex]::Match('$(VisualStudioVersion)', '^\d+(\.\d+)*').Value)).Major)</VisualStudioMajorVersion>
38+
<IsLegacyVisualStudioVersion>false</IsLegacyVisualStudioVersion>
39+
<!-- Visual Studio 2026 == Version 18.x - anything below that major version is legacy -->
40+
<IsLegacyVisualStudioVersion Condition="'$(BuildingInsideVisualStudio)' == 'true' And '$(VisualStudioMajorVersion)' &lt; '18'">true</IsLegacyVisualStudioVersion>
41+
</PropertyGroup>
42+
3443
<PropertyGroup Label="Centralized Target Frameworks">
35-
<!-- Base frameworks without net10.0 -->
36-
<LibraryTargetFrameworksBase>net8.0;netstandard2.0;net462</LibraryTargetFrameworksBase>
37-
<NetCoreOnlyTargetFrameworksBase>net8.0</NetCoreOnlyTargetFrameworksBase>
44+
<!-- net10.0 is conditional on VS version (VS2024+ = 18.0) -->
45+
<!-- .NET Framework and netstandard2.0 are conditional on VS version (VS2024+ = 18.0) due to invalid build warnings with C# 14.0 build features -->
3846

39-
<!-- Add net10.0 conditionally based on VS version (VS2024+ = 18.0) -->
40-
<LibraryTargetFrameworks Condition=" '$(VisualStudioVersion)' &gt;= '18.0' ">net10.0;$(LibraryTargetFrameworksBase)</LibraryTargetFrameworks>
41-
<LibraryTargetFrameworks Condition=" '$(VisualStudioVersion)' &lt; '18.0' Or '$(VisualStudioVersion)' == '' ">$(LibraryTargetFrameworksBase)</LibraryTargetFrameworks>
47+
<LibraryTargetFrameworks>net10.0;net8.0;netstandard2.0;net462</LibraryTargetFrameworks>
48+
<LibraryTargetFrameworks Condition=" '$(IsLegacyVisualStudioVersion)' == 'true' ">net8.0</LibraryTargetFrameworks>
4249

43-
<NetCoreOnlyTargetFrameworks Condition=" '$(VisualStudioVersion)' &gt;= '18.0' ">net10.0;$(NetCoreOnlyTargetFrameworksBase)</NetCoreOnlyTargetFrameworks>
44-
<NetCoreOnlyTargetFrameworks Condition=" '$(VisualStudioVersion)' &lt; '18.0' Or '$(VisualStudioVersion)' == '' ">$(NetCoreOnlyTargetFrameworksBase)</NetCoreOnlyTargetFrameworks>
50+
<NetCoreOnlyTargetFrameworks>net10.0;net8.0</NetCoreOnlyTargetFrameworks>
51+
<NetCoreOnlyTargetFrameworks Condition=" '$(IsLegacyVisualStudioVersion)' == 'true' ">net8.0</NetCoreOnlyTargetFrameworks>
4552
</PropertyGroup>
4653

4754
<!-- IMPORTANT: When these values are changed, the CI counter number should also be reset. -->

0 commit comments

Comments
 (0)