diff --git a/src/app/FakeLib/ProcessHelper.fs b/src/app/FakeLib/ProcessHelper.fs index 80ddba10b25..598e8bc0131 100644 --- a/src/app/FakeLib/ProcessHelper.fs +++ b/src/app/FakeLib/ProcessHelper.fs @@ -12,6 +12,15 @@ open System.Collections.Generic open System.Collections.Concurrent open System.ServiceProcess + +/// 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 + /// [omit] type internal ConcurrentBag<'T> with member internal this.Clear() = @@ -23,14 +32,16 @@ let startedProcesses = ConcurrentBag() /// [omit] let start (proc : Process) = - try - System.Console.OutputEncoding <- System.Text.Encoding.UTF8 - with exn -> - logfn "Failed setting UTF8 console encoding, ignoring error... %s." exn.Message + if isMono || AlwaysSetProcessEncoding then + try + System.Console.OutputEncoding <- System.Text.Encoding.UTF8 + with exn -> + logfn "Failed setting UTF8 console encoding, ignoring error... %s." exn.Message if isMono && proc.StartInfo.FileName.ToLowerInvariant().EndsWith(".exe") then proc.StartInfo.Arguments <- "--debug \"" + proc.StartInfo.FileName + "\" " + proc.StartInfo.Arguments proc.StartInfo.FileName <- monoPath + proc.Start() |> ignore startedProcesses.Add(proc.Id, proc.StartTime) |> ignore @@ -57,6 +68,7 @@ type ProcessResult = Messages = messages Errors = errors } + /// Runs the given process and returns the exit code. /// ## Parameters /// @@ -77,9 +89,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 ->