public override int ExecuteSyncCommand(string commandDescription, string commandText, int timeout, out string output, out string error) { output = null; error = null; int exitCode = -1; Process proc = new Process(); proc.StartInfo.FileName = _pipePath; proc.StartInfo.Arguments = PipeLaunchOptions.ReplaceDebuggerCommandToken(_cmdArgs, commandText, true); Logger.WriteLine("Running process {0} {1}", proc.StartInfo.FileName, proc.StartInfo.Arguments); proc.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(_pipePath); proc.EnableRaisingEvents = false; proc.StartInfo.RedirectStandardInput = false; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.RedirectStandardError = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.CreateNoWindow = true; proc.Start(); proc.WaitForExit(timeout); exitCode = proc.ExitCode; output = proc.StandardOutput.ReadToEnd(); error = proc.StandardError.ReadToEnd(); return(exitCode); }
private int WrappedExecuteSyncCommand(string commandDescription, string commandText, int timeout) { int exitCode = -1; string output = null; string error = null; string pipeArgs = PipeLaunchOptions.ReplaceDebuggerCommandToken(_cmdArgs, commandText, true); string fullCommand = string.Format(CultureInfo.InvariantCulture, "{0} {1}", _pipePath, pipeArgs); try { exitCode = ExecuteSyncCommand(commandDescription, commandText, timeout, out output, out error); if (exitCode != 0) { this.Callback.OnStdErrorLine(string.Format(CultureInfo.InvariantCulture, MICoreResources.Warn_ProcessExit, fullCommand, exitCode)); } } catch (Exception e) { this.Callback.OnStdErrorLine(string.Format(CultureInfo.InvariantCulture, MICoreResources.Warn_ProcessException, fullCommand, e.Message)); } return(exitCode); }