2012-10-30 32 views
0

在Mono/OSX上的控制檯應用程序中,我想調用mdtool來構建iOS項目。我成功地擁有了正確的命令行參數,並且它在bash shell腳本中正確運行。單聲道開始進程mdtool關閉調用者

現在,如果我在我的控制檯應用程序中使用Process/ProcessStartInfo類調用它,構建後我得到了這個,我的程序退出。

Press any key to continue... logout 

[Process completed] 

下面的代碼來調用mdtool:

var buildArgs = string.Format("..."); 

var buildiOSproject = new ProcessStartInfo 
{ 
    FileName = "/Applications/MonoDevelop.app/Contents/MacOS/mdtool", 
    UseShellExecute = false, 
    Arguments = buildArgs 
}; 
var exeProcess = Process.Start(buildiOSproject); 
exeProcess.WaitForExit(); 
//code here never called 

回答

0

我得到了我的Xamarin論壇答案(http://forums.xamarin.com/discussion/267/calling-mdtool-trough- processstartinfo#latest),但它似乎是調試器的問題,所以我關閉了在我的項目的選項中的「在外部控制檯上運行」屬性,現在它正在工作。

0

嘗試將以下內容添加到StartInfo初始值設定項中。我退出時遇到了另一個工具的相同問題。雖然我已經使用過RedirectStandardOutput和RedirectStandardError,但是我在添加RedirectStandardInput後才解決了它。

  buildiOSproject.StartInfo = new ProcessStartInfo 
      { 
... 
       RedirectStandardOutput = true, 
       RedirectStandardError = true, 
       RedirectStandardInput = true, 
... 
      }