Exemplo n.º 1
0
 public InstallerForm(IProcessOutput process, string workingPath)
 {
     InitializeComponent();
     _process     = process;
     _workingPath = workingPath;
     Status       = InstallerStatus.Processing;
     Text         = $"{_process.Label} Log";
 }
        /// <summary>
        /// Logs the process StdOut and StdErr to the destination, then clears both output buffers.
        /// </summary>
        /// <param name="logger">The logger to write to.</param>
        /// <param name="output">The <see cref="IProcessOutput"/> to write.</param>
        public static void LogAndClear(this ILogger logger, IProcessOutput output)
        {
            string name =
                $"{output.ProcessStartInfo.FileName} {output.ProcessStartInfo.Arguments}, working directory {output.ProcessStartInfo.WorkingDirectory}";

            logger.LogInformation("StdOut for process {Name}: {StdOut}", name, output.StandardOutputText);

            string stdErr = output.StandardErrorText;

            if (!string.IsNullOrEmpty(stdErr))
            {
                logger.LogWarning("StdErr for process {Name}: {StdErr}", name, stdErr);
            }

            output.ClearAllOutput();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Writes the process StdOut and StdErr to the console, then clears both output buffers.
        /// </summary>
        /// <param name="output">The <see cref="IProcessOutput"/> to write.</param>
        public static void WriteToConsoleAndClear(this IProcessOutput output)
        {
            string name =
                $"{output.ProcessStartInfo.FileName} {output.ProcessStartInfo.Arguments}, working directory {output.ProcessStartInfo.WorkingDirectory}";

            Console.WriteLine($"\nStdOut for process {name}:");
            Console.WriteLine(output.StandardOutputText);
            Console.WriteLine();

            string stdErr = output.StandardErrorText;

            if (!string.IsNullOrEmpty(stdErr))
            {
                Console.WriteLine($"\nStdErr for process {name}:");
                Console.WriteLine(stdErr);
                Console.WriteLine();
            }

            output.ClearAllOutput();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Instantiates an instance of the CommandLineBuilder class.
 /// </summary>
 /// <param name="process"></param>
 /// <param name="workingPath"></param>
 public CommandLineBuilder(IProcessOutput process, string workingPath)
 {
     _process     = process;
     _workingPath = workingPath;
 }