在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发布于 2012-12-01 22:05:08
我在Xamarin论坛(http://forums.xamarin.com/discussion/267/calling-mdtool-trough-processstartinfo#latest)上得到了答案,但这似乎是调试器的问题,所以我在项目的选项中关闭了“在外部控制台上运行”属性,现在它可以工作了。
发布于 2016-03-25 06:02:27
尝试将以下内容添加到StartInfo初始化器中。当另一个工具退出时,我也遇到了同样的问题。虽然我已经使用了RedirectStandardOutput和RedirectStandardError,但我也是在添加了RedirectStandardInput之后才修复它的。
buildiOSproject.StartInfo = new ProcessStartInfo
{
...
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true,
...
}https://stackoverflow.com/questions/13147337
复制相似问题