0

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
MatthieuGD
  • 4,552
  • 2
  • 30
  • 29

2 Answers2

0

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.

MatthieuGD
  • 4,552
  • 2
  • 30
  • 29
0

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,
...
            }
Ajean
  • 5,528
  • 14
  • 46
  • 69
AdvanTiSS
  • 336
  • 3
  • 8