示例#1
0
        public void Execute(string command, string commandType = "")
        {
            var startInfo = new ProcessStartInfo
            {
                FileName               = _shell.GetFileName(),
                Arguments              = _shell.CommandConstructor(command),
                RedirectStandardInput  = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                UseShellExecute        = false,
                CreateNoWindow         = true,
                StandardErrorEncoding  = Encoding.UTF8,
                StandardOutputEncoding = Encoding.UTF8
            };

            _logger.Log(string.Empty);
            _logger.Log($"Starting {commandType} command..");
            using (var process = Process.Start(startInfo))
            {
                process.WaitForExit();
                _logger.Log(process.StandardOutput.ReadToEnd());
                _logger.Log(process.StandardError.ReadToEnd());
                _logger.Log($"Process finished with exit code: {process.ExitCode.ToString()}");
                _logger.Log($"Command {commandType} finished");
                _logger.Log(string.Empty);
            }
        }
示例#2
0
        private ProcessStartInfo GetProcessStartInfo(string fullDockerCommand)
        {
            var startInfo = new ProcessStartInfo
            {
                FileName               = _shell.GetFileName(),
                Arguments              = _shell.CommandConstructor(fullDockerCommand),
                RedirectStandardInput  = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                UseShellExecute        = false,
                CreateNoWindow         = true,
                StandardErrorEncoding  = Encoding.UTF8,
                StandardOutputEncoding = Encoding.UTF8
            };

            return(startInfo);
        }