diff --git a/src/Scripty.MsBuild/ScriptyTask.cs b/src/Scripty.MsBuild/ScriptyTask.cs index c44bfc5..ecdc16a 100644 --- a/src/Scripty.MsBuild/ScriptyTask.cs +++ b/src/Scripty.MsBuild/ScriptyTask.cs @@ -72,6 +72,12 @@ public override bool Execute() return false; } + // Some build environments by default use non-UTF8 character encodings. This + // fixes issues in those environments by forcing the character encoding to match + // the decoding in the target process. + Console.InputEncoding = Encoding.UTF8; + Console.OutputEncoding = Encoding.UTF8; + // Kick off the evaluation process, which must be done in a seperate process space // otherwise MSBuild complains when we construct the Roslyn workspace project since // it uses MSBuild to figure out what the project contains and MSBuild only supports diff --git a/src/Scripty/Settings.cs b/src/Scripty/Settings.cs index 90f1c6a..8abcfa9 100644 --- a/src/Scripty/Settings.cs +++ b/src/Scripty/Settings.cs @@ -64,6 +64,12 @@ private KeyValuePair ParseProperty(string argument) public void ReadStdin() { + // Some build environments by default use non-UTF8 character encodings. This + // fixes issues in those environments by forcing the character encoding to match + // the decoding in the target process. + Console.InputEncoding = Encoding.UTF8; + Console.OutputEncoding = Encoding.UTF8; + string stdin = Console.In.ReadToEnd(); JsonConvert.PopulateObject(stdin, this); }