diff --git a/Source/cmVSSolution.cxx b/Source/cmVSSolution.cxx
index 2fc6fca630..7b0c04e67b 100644
--- a/Source/cmVSSolution.cxx
+++ b/Source/cmVSSolution.cxx
@@ -331,7 +331,10 @@ void WriteSlnxProject(cmXMLElement& xmlParent, Solution const& solution,
.Attribute("Solution", cmStrCat(solution.Configs[i], "|*"));
}
}
- if (project.Platform != solution.Platform) {
+ 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) {
cmXMLElement(xmlProject, "Platform")
.Attribute("Project", project.Platform);
}
diff --git a/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkTargetPlatform-check-slnx.cmake b/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkTargetPlatform-check-slnx.cmake
index 7ab421de7b..f1f7492c1c 100644
--- a/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkTargetPlatform-check-slnx.cmake
+++ b/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkTargetPlatform-check-slnx.cmake
@@ -19,5 +19,6 @@ RunCMake_check_slnx("${RunCMake_TEST_BINARY_DIR}/VsDotnetSdkTargetPlatform.slnx"
+
$]])
diff --git a/Tests/RunCMake/include_external_msproject/AutoType-check-slnx.cmake b/Tests/RunCMake/include_external_msproject/AutoType-check-slnx.cmake
index 4a4a1cb1b2..560c9c0229 100644
--- a/Tests/RunCMake/include_external_msproject/AutoType-check-slnx.cmake
+++ b/Tests/RunCMake/include_external_msproject/AutoType-check-slnx.cmake
@@ -26,6 +26,7 @@ RunCMake_check_slnx("${RunCMake_TEST_BINARY_DIR}/AutoType.slnx" [[
+