簡體   English   中英

我如何在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\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屏幕的任何參數嗎? 或將輸出寫入日志文件?

我會嘗試啟動msbuild.exe在此處顯示實際的cmd.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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM