我尝试使用代码在执行msbuild.exe后暂停命令行界面
var solutionFile = "c:\test\myconsole.sln";
regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSBuild\ToolsVersions\3.5");
var msbuildPath = (string)regKey.GetValue("MSBuildToolsPath");;
var startInfo = new ProcessStartInfo()
{
Arguments = String.Format("\"{0}\" /nologo", solutionFile),
FileName = Path.Combine(msbuildPath, "msbuild.exe")
};
var proc = Process.Start(startInfo);
proc.WaitForExit();
我可以用来暂停cmd屏幕的任何参数?或者在日志文件中写出输出?
答案 0 :(得分:2)
我会尝试在显示here内的实际cmd.exe中启动msbuild.exe
。
修改强>
const string solutionFile = @"c:\test\myconsole.sln";
var regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSBuild\ToolsVersions\3.5");
var msbuildPath = (string) regKey.GetValue("MSBuildToolsPath");
var msBuild = Path.Combine(msbuildPath, "msbuild.exe");
var strCmdText = string.Format("/K {0} \"{1}\" /nologo", msBuild, solutionFile);
var proc = Process.Start("CMD.exe", strCmdText);
// Not necessary if you don't actually want to wait for it to exit before
// proceeding to following code
proc.WaitForExit();