From 50def30b0d5897097dca15197335a24a62c59c16 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Thu, 29 Jun 2017 08:40:47 +0200 Subject: [PATCH] Allow to set process encoding - fixes #1215 --- src/app/FakeLib/ProcessHelper.fs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/FakeLib/ProcessHelper.fs b/src/app/FakeLib/ProcessHelper.fs index 80ddba10b25..f82887d2334 100644 --- a/src/app/FakeLib/ProcessHelper.fs +++ b/src/app/FakeLib/ProcessHelper.fs @@ -57,6 +57,14 @@ type ProcessResult = Messages = messages Errors = errors } +/// If set to true the ProcessHelper will start all processes with a custom ProcessEncoding. +/// If set to false (default) only mono processes will be changed. +let mutable AlwaysSetProcessEncoding = false + +/// The ProcessHelper will start all processes with this encoding if AlwaysSetProcessEncoding is set to true. +/// If AlwaysSetProcessEncoding is set to false (default) only mono processes will be changed. +let mutable ProcessEncoding = Encoding.UTF8 + /// Runs the given process and returns the exit code. /// ## Parameters /// @@ -77,9 +85,9 @@ let ExecProcessWithLambdas configProcessStartInfoF (timeOut : TimeSpan) silent e if silent then proc.StartInfo.RedirectStandardOutput <- true proc.StartInfo.RedirectStandardError <- true - if isMono then - proc.StartInfo.StandardOutputEncoding <- Encoding.UTF8 - proc.StartInfo.StandardErrorEncoding <- Encoding.UTF8 + if isMono || AlwaysSetProcessEncoding then + proc.StartInfo.StandardOutputEncoding <- ProcessEncoding + proc.StartInfo.StandardErrorEncoding <- ProcessEncoding proc.ErrorDataReceived.Add(fun d -> if d.Data <> null then errorF d.Data) proc.OutputDataReceived.Add(fun d ->