public void RunTool ( string exePath, string commandLine )
{
//commandLine = FixEncoding(commandLine);
Log.Debug("...exec: {0} {1}", exePath, commandLine );
ProcessStartInfo psi = new ProcessStartInfo();
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.FileName = ResolvePath( exePath, binaryPaths );
psi.Arguments = commandLine;
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
int exitCode = 0;
string stdout = "";
string stderr = "";
using ( Process proc = Process.Start( psi ) ) {
stdout = proc.StandardOutput.ReadToEnd().Trim(new[]{'\r', '\n'});
stderr = proc.StandardError.ReadToEnd().Trim(new[]{'\r', '\n'});
proc.WaitForExit();
exitCode = proc.ExitCode;
}
Log.Verbose( "{0}", stdout ); //*/
if ( exitCode != 0 ) {
File.WriteAllText( @"C:\GITHUB\stderr.txt", commandLine);
throw new ToolException( string.Format("Failed to launch tool:\r\n{0} {1}\r\n{2}", exePath, commandLine, stderr ) );
} else {
if (!string.IsNullOrWhiteSpace(stderr)) {
Log.Warning( "{0}", stderr.Trim(new[]{'\r', '\n'}) );
}
}
}
}