From 0c979127560c56f97836abcb383df63be088933b Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 19 Jan 2026 14:19:24 -0500 Subject: VS: Fix SLNX generation so .NET Core projects build in the IDE Extend commit 46b0202ce0 (VS: Fix SLNX generation so CSharp projects build in the IDE, 2025-10-23, v4.2.0-rc2~26^2) to cover .NET Core projects. Fixes: #27524 --- Source/cmVSSolution.cxx | 16 +++++++++++++--- .../include_external_msproject/ProjType-check-slnx.cmake | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Source/cmVSSolution.cxx b/Source/cmVSSolution.cxx index cb2b259..c8d4775 100644 --- a/Source/cmVSSolution.cxx +++ b/Source/cmVSSolution.cxx @@ -311,6 +311,18 @@ void WriteSln(std::ostream& sln, Solution const& solution) } namespace { + +bool NeedExplicitProjectPlatform(cm::string_view typeId) +{ + // Some projects do not build interactively in the VS IDE unless they + // have an explicit platform, even if it matches the SLN platform. + if (typeId == Solution::Project::TypeIdCSharp || + typeId == Solution::Project::TypeIdDotNetCore) { + return true; + } + return false; +} + void WriteSlnxSolutionConfigurationPlatforms(cmXMLElement& xmlParent, Solution const& solution) { @@ -353,9 +365,7 @@ void WriteSlnxProject(cmXMLElement& xmlParent, Solution const& solution, } } if (project.Platform != solution.Platform || - // C# projects do not build interactively in the VS IDE unless they - // have an explicit platform, even if it matches the SLN platform. - project.TypeId == Solution::Project::TypeIdCSharp) { + NeedExplicitProjectPlatform(project.TypeId)) { cmXMLElement(xmlProject, "Platform") .Attribute("Project", project.Platform); } diff --git a/Tests/RunCMake/include_external_msproject/ProjType-check-slnx.cmake b/Tests/RunCMake/include_external_msproject/ProjType-check-slnx.cmake index f1fd0fc..67aba13 100644 --- a/Tests/RunCMake/include_external_msproject/ProjType-check-slnx.cmake +++ b/Tests/RunCMake/include_external_msproject/ProjType-check-slnx.cmake @@ -26,6 +26,7 @@ RunCMake_check_slnx("${RunCMake_TEST_BINARY_DIR}/ProjType.slnx" [[ + -- cgit v0.12