0

在 Mono/OSX 上的控制台应用程序中,我想调用 mdtool 来构建 iOS 项目。我成功地拥有了正确的命令行参数,并且它在 bash shell 脚本中正确运行。

现在,如果我在控制台应用程序中使用 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
4

2 回答 2

0

我在 Xamarin 论坛 (http://forums.xamarin.com/discussion/267/calling-mdtool-trough-processstartinfo#latest) 上得到了答案,但调试器似乎有问题,所以我关闭了“在外部运行我的项目选项中的控制台“属性,它现在正在工作。

于 2012-12-01T14:05:08.157 回答
0

尝试将以下内容添加到您的 StartInfo 初始化程序。当另一个工具退出时,我遇到了同样的问题。虽然我已经使用了 RedirectStandardOutput 和 RedirectStandardError,但我也只是在添加了 RedirectStandardInput 之后才修复它。

            buildiOSproject.StartInfo = new ProcessStartInfo
            {
...
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                RedirectStandardInput = true,
...
            }
于 2016-03-24T22:02:26.633 回答