Mono Start Process mdtool Close the Caller

239 views Asked by At

In a console app on Mono/OSX I want to call the mdtool to build an iOS project. I succeed to have the right command line arguments and it runs correctly in bash shell script.

Now If I call it with the Process/ProcessStartInfo classes in my console app, after the build I got this and my programm exits.

Press any key to continue... logout

[Process completed]

Here's the code to call 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
2

There are 2 answers

0
MatthieuGD On BEST ANSWER

I got my answer on the Xamarin forums (http://forums.xamarin.com/discussion/267/calling-mdtool-trough-processstartinfo#latest) but it seems a problem with the debugger so I switch off the "Run on external console" property in the options of my project and it's working now.

0
AdvanTiSS On

Try adding the following to your StartInfo initializer. I faced the same problem with another tool when it exited. Although I had already used RedirectStandardOutput and RedirectStandardError, I got it fixed only after adding RedirectStandardInput also.

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