public CommandResult Execute(CommandLineInvocation invocation) { try { var exitCode = SilentProcessRunner.ExecuteCommand( invocation.Executable, invocation.Arguments, invocation.WorkingDirectory, invocation.EnvironmentVars, invocation.UserName, invocation.Password, commandOutput.WriteInfo, commandOutput.WriteError); return(new CommandResult( invocation.ToString(), exitCode.ExitCode, exitCode.ErrorOutput, invocation.WorkingDirectory)); } catch (Exception ex) { Console.Error.WriteLine(ex); Console.Error.WriteLine("The command that caused the exception was: " + invocation); return(new CommandResult( invocation.ToString(), -1, ex.ToString(), invocation.WorkingDirectory)); } }
public CommandResult Execute(CommandLineInvocation invocation) { var commandOutput = new SplitCommandInvocationOutputSink(GetCommandOutputs(invocation)); try { var exitCode = SilentProcessRunner.ExecuteCommand( invocation.Executable, invocation.Arguments, invocation.WorkingDirectory, invocation.EnvironmentVars, invocation.UserName, invocation.Password, commandOutput.WriteInfo, commandOutput.WriteError); return(new CommandResult( invocation.ToString(), exitCode.ExitCode, exitCode.ErrorOutput, invocation.WorkingDirectory)); } catch (Exception ex) { if (ex.InnerException is Win32Exception) { commandOutput.WriteError(ConstructWin32ExceptionMessage(invocation.Executable)); } commandOutput.WriteError(ex.ToString()); commandOutput.WriteError("The command that caused the exception was: " + invocation); return(new CommandResult( invocation.ToString(), -1, ex.ToString(), invocation.WorkingDirectory)); } }