Skip to content

Commit

Permalink
Allow to set process encoding - fixes #1215
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jun 29, 2017
1 parent e104db3 commit 50def30
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/app/FakeLib/ProcessHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -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 ->
Expand Down

0 comments on commit 50def30

Please sign in to comment.