public int GetOutputStreams(string workingDirectory, string command, string param, out List<string> standardOut, out List<string> standardErr)
        {
            Process process = CreateProcess(workingDirectory, command, param);

            var localStandardOut = new List<string>();
            var localStandardErr = new List<string>();
            process.OutputDataReceived += (sender, e) => localStandardOut.Add(e.Data);
            process.ErrorDataReceived += (sender, e) => localStandardErr.Add(e.Data);

            try
            {
                process.Start();
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();

                var waiter = new ProcessWaiter(process);
                waiter.WaitForExit();

                standardOut = localStandardOut.Where(s => s != null).ToList();
                standardErr = localStandardErr.Where(s => s != null).ToList();
                return waiter.ProcessExitCode;
            }
            finally
            {
                process.Dispose();
            }
        }
 private int LaunchProcessWithDebuggerAttached(string workingDirectory, string command, string param, bool printTestOutput,
     IDebuggedProcessLauncher handle)
 {
     _testEnvironment.LogInfo("Attaching debugger to " + command);
     if (printTestOutput)
     {
         _testEnvironment.DebugInfo(
             "Note that due to restrictions of the VS Unit Testing framework, the test executable's output can not be displayed in the test console when debugging tests!");
     }
     int processId = handle.LaunchProcessWithDebuggerAttached(command, workingDirectory, param, _testEnvironment.Options.GetPathExtension(command));
     Process process = Process.GetProcessById(processId);
     var waiter = new ProcessWaiter(process);
     waiter.WaitForExit();
     process.Dispose();
     return waiter.ProcessExitCode;
 }
        private int LaunchProcess(string workingDirectory, string command, string param, bool printTestOutput,
            bool throwIfError, List<string> output)
        {
            var processStartInfo = new ProcessStartInfo(command, param)
            {
                RedirectStandardOutput = true,
                RedirectStandardError = false,
                UseShellExecute = false,
                CreateNoWindow = true,
                WorkingDirectory = workingDirectory
            };

            if (!string.IsNullOrEmpty(_pathExtension))
                processStartInfo.EnvironmentVariables["PATH"] = Utils.GetExtendedPath(_pathExtension);

            Process process = Process.Start(processStartInfo);
            try
            {
                var waiter = new ProcessWaiter(process);
                if (printTestOutput)
                {
                    _logger.LogInfo(
                        ">>>>>>>>>>>>>>> Output of command '" + command + " " + param + "'");
                }
                ReadTheStream(process, output, printTestOutput, throwIfError);
                if (printTestOutput)
                {
                    _logger.LogInfo("<<<<<<<<<<<<<<< End of Output");
                }
                return waiter.WaitForExit();
            }
            finally
            {
                process?.Dispose();
            }
        }