From 14314944358424b8dcb1a743c11c5858b9858973 Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Mon, 25 Nov 2024 12:39:29 +0100 Subject: [PATCH 1/2] Fix LangVersion computation on non-English locales --- src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets b/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets index f11e8b1adcf90..995f63d158043 100644 --- a/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets +++ b/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets @@ -20,7 +20,7 @@ to determine the correct language version. --> <_MaxSupportedLangVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND - '$(_MaxSupportedLangVersion)' == ''">$([MSBuild]::Add(9, $([MSBuild]::Subtract($(_TargetFrameworkVersionWithoutV), 5)))).0 + '$(_MaxSupportedLangVersion)' == ''">$([MSBuild]::Add(9, $([MSBuild]::Subtract($(_TargetFrameworkVersionWithoutV.Split('.')[0]), 5)))).0 <_MaxAvailableLangVersion>13.0 From 9a1c79c2d16c233a9523a2b596b9b00866870421 Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Mon, 25 Nov 2024 15:09:28 +0100 Subject: [PATCH 2/2] Add link to MSBuild issue --- src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets b/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets index 995f63d158043..e595f62d2c33a 100644 --- a/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets +++ b/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets @@ -18,6 +18,7 @@ - Pattern: .NET 5.0 uses C# 9.0, .NET 6.0 uses C# 10.0, and so on. - Starting from C# 9.0 for .NET 5.0, we add the difference between the major .NET version and 5 to determine the correct language version. + NOTE: `.Split('.')[0]` needed due to https://github.com/dotnet/msbuild/issues/9757. --> <_MaxSupportedLangVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_MaxSupportedLangVersion)' == ''">$([MSBuild]::Add(9, $([MSBuild]::Subtract($(_TargetFrameworkVersionWithoutV.Split('.')[0]), 5)))).0