title: Execute cmd.exe command (webpack) on windows with .NET Core and preserve colors and output
body: <p>How can I execute cmd command (<code>webpack</code>) from .NET Core - console app and preserve colors?</p>
  
  <p>This is my current code:</p>
  
  <pre><code>static void Main(string[] args)
  {
      var dir = args.First();
      //build:vendor -&gt; webpack --config webpack.config.vendor.js --progress --color --display-error-details
      Console.WriteLine("npm run build:vendor -- --env.prod".Execute(dir));
      Console.ReadKey();
  }
  
  public static string Execute(this string cmd, string startDir)
  {
      var process = new Process()
      {
          StartInfo = new ProcessStartInfo
          {
              FileName = "cmd.exe",
              Arguments = $"/c {cmd}",
              RedirectStandardOutput = true,
              UseShellExecute = false,
              CreateNoWindow = true,
              WorkingDirectory = startDir
          }
      };
      process.Start();
      string result = process.StandardOutput.ReadToEnd();
      process.WaitForExit();
      return result;
  }
  </code></pre>
  
  <p>My output:
  <a href="https://i.stack.imgur.com/DkHWB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DkHWB.png" alt="current output"></a></p>
  
  <p>Expected output:
  <a href="https://i.stack.imgur.com/PFcoq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PFcoq.png" alt="expected output"></a></p>
  
  <p>I see 2 problems:
  when I run command</p>
  
  <ul>
  <li>from cmd.exe, progress is displayed in percents but running command
  from dotnet outputs strange characters ... </li>
  <li>colors are missing</li>
  </ul>