Przeglądaj źródła

VS: Add missing label in C# project-build events

Fixes: #21440
Steven Boswell 4 lat temu
rodzic
commit
b284a21fee

+ 2 - 2
Source/cmLocalVisualStudio7Generator.cxx

@@ -566,7 +566,7 @@ public:
     } else {
       this->Stream << this->LG->EscapeForXML("\n");
     }
-    std::string script = this->LG->ConstructScript(ccg);
+    std::string script = this->LG->ConstructScript(ccg, unmanaged);
     this->Stream << this->LG->EscapeForXML(script);
   }
 
@@ -1779,7 +1779,7 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
     }
 
     std::string comment = this->ConstructComment(ccg);
-    std::string script = this->ConstructScript(ccg);
+    std::string script = this->ConstructScript(ccg, unmanaged);
     if (this->FortranProject) {
       cmSystemTools::ReplaceString(script, "$(Configuration)", config);
     }

+ 10 - 1
Source/cmLocalVisualStudioGenerator.cxx

@@ -124,7 +124,8 @@ const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const
 }
 
 std::string cmLocalVisualStudioGenerator::ConstructScript(
-  cmCustomCommandGenerator const& ccg, const std::string& newline_text)
+  cmCustomCommandGenerator const& ccg, IsManaged isManaged,
+  const std::string& newline_text)
 {
   bool useLocal = this->CustomCommandUseLocal();
   std::string workingDirectory = ccg.GetWorkingDirectory();
@@ -236,6 +237,14 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
     script += newline;
     script += "if %errorlevel% neq 0 goto ";
     script += this->GetReportErrorLabel();
+    if (isManaged == managed) {
+      // These aren't generated by default for C# projects.
+      script += newline;
+      script += this->GetReportErrorLabel();
+      script += newline;
+      script += "exit /b 0";
+      script += newline;
+    }
   }
 
   return script;

+ 6 - 0
Source/cmLocalVisualStudioGenerator.h

@@ -31,7 +31,13 @@ public:
   virtual ~cmLocalVisualStudioGenerator();
 
   /** Construct a script from the given list of command lines.  */
+  enum IsManaged
+  {
+    unmanaged,
+    managed
+  };
   std::string ConstructScript(cmCustomCommandGenerator const& ccg,
+                              IsManaged isManaged,
                               const std::string& newline = "\n");
 
   /** Label to which to jump in a batch file after a failed step in a

+ 8 - 2
Source/cmVisualStudio10TargetGenerator.cxx

@@ -1465,7 +1465,10 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
     cmCustomCommandGenerator ccg(command, c, lg, true);
     std::string comment = lg->ConstructComment(ccg);
     comment = cmVS10EscapeComment(comment);
-    std::string script = lg->ConstructScript(ccg);
+    cmLocalVisualStudioGenerator::IsManaged isManaged = (this->Managed)
+      ? cmLocalVisualStudioGenerator::managed
+      : cmLocalVisualStudioGenerator::unmanaged;
+    std::string script = lg->ConstructScript(ccg, isManaged);
     bool symbolic = false;
     // input files for custom command
     std::stringstream additional_inputs;
@@ -4205,7 +4208,10 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
       comment += lg->ConstructComment(ccg);
       script += pre;
       pre = "\n";
-      script += lg->ConstructScript(ccg);
+      cmLocalVisualStudioGenerator::IsManaged isManaged = (this->Managed)
+        ? cmLocalVisualStudioGenerator::managed
+        : cmLocalVisualStudioGenerator::unmanaged;
+      script += lg->ConstructScript(ccg, isManaged);
 
       stdPipesUTF8 = stdPipesUTF8 || cc.GetStdPipesUTF8();
     }