【发布时间】:2017-11-02 00:43:48
【问题描述】:
我正在尝试在控制台应用程序中使用 system 关键字编译项目以调用 MSBuild。 MSBuild 吐出一个项目未找到错误,我不知道为什么。路径和项目名称都正确并打印出来。 https://gyazo.com/624847f060e242ad702f16174ac75701
我的代码:
bool MSBuild::compile(std::string path, std::string solution) {
if (path.length() == 0 || solution.length() == 0)
return false;
std::string cmd1 = "cd ";
cmd1.append(path);
std::cout << "Command: " << cmd1 << std::endl;
std::string cmd2 = "msbuild ";
cmd2.append(solution);
cmd2.append(" /p:configuration=debug");
std::cout << "Command: " << cmd2 << std::endl;
system(cmd1.c_str());
system(cmd2.c_str());
return true;
}
我已经确认 MSBuild 在手动输入具有相同参数的相同命令到 cmd 窗口时成功编译项目。 https://gyazo.com/a7f4c3f07f3f44b418734f4a979ca398
【问题讨论】: