diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index cc2536c4392ee26881607c8ad6e1c98e2c75d915..ced0c266b89003e16698cb39a8ec09f14b02b1e1 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -750,6 +750,10 @@ bool cmGlobalVisualStudioGenerator::TargetIsCSharpOnly(
     if (!gt->GetConfigCommonSourceFiles(sources)) {
       return false;
     }
+    // Only "real" targets are allowed to be C# targets.
+    if (gt->Target->GetType() > cmStateEnums::OBJECT_LIBRARY) {
+      return false;
+    }
   }
   gt->GetLanguages(languages, "");
   if (languages.size() == 1) {