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
This commit is contained in:
Brad King
2026-01-19 14:19:24 -05:00
parent 7ce9185792
commit 0c97912756
2 changed files with 14 additions and 3 deletions

View File

@@ -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);
}

View File

@@ -26,6 +26,7 @@ RunCMake_check_slnx("${RunCMake_TEST_BINARY_DIR}/ProjType.slnx" [[
</Project>
<Project Path="DotNetCore.project" Type="9a19103f-16f7-4668-be54-9a1e7a4f7556" Id="[0-9a-f-]+">
<BuildDependency Project="ZERO_CHECK\.vcxproj"/>
<Platform Project="[^"]+"/>
</Project>
<Project Path="JScript.project" Type="262852c6-cd72-467d-83fe-5eeb1973a190" Id="[0-9a-f-]+">
<BuildDependency Project="ZERO_CHECK\.vcxproj"/>