如何在 msbuild.exe 执行后暂停 cmd 屏幕或将输出写入日志文件?
how do i pause cmd screen after msbuild.exe execution or write output in log file?
我尝试使用以下代码在执行 msbuild.exe
后暂停命令行屏幕
var solutionFile = "c:\test\myconsole.sln";
regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSBuild\ToolsVersions.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 屏幕吗?或者在日志文件中写入输出?
我会尝试在实际 cmd.exe 内启动 msbuild.exe
,如 here 所示。
编辑
const string solutionFile = @"c:\test\myconsole.sln";
var regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSBuild\ToolsVersions.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();
我尝试使用以下代码在执行 msbuild.exe
后暂停命令行屏幕var solutionFile = "c:\test\myconsole.sln";
regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSBuild\ToolsVersions.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 屏幕吗?或者在日志文件中写入输出?
我会尝试在实际 cmd.exe 内启动 msbuild.exe
,如 here 所示。
编辑
const string solutionFile = @"c:\test\myconsole.sln";
var regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSBuild\ToolsVersions.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();