1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-15 03:48:02 +08:00

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

Fixes: #21440
This commit is contained in:
Steven Boswell
2021-09-03 14:06:27 -07:00
committed by Brad King
parent ed9abd9977
commit b284a21fee
4 changed files with 26 additions and 5 deletions

View File

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

View File

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

View File

@@ -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

View File

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