File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ namespace Microsoft.Build.Logging.LiveLogger;
1616internal sealed class Terminal : ITerminal
1717{
1818 /// <summary>
19- /// The encoding read from <see cref="Console.OutputEncoding"/> when the terminal is instantiated .
19+ /// The encoding read from <see cref="Console.OutputEncoding"/> when the terminal is constructed .
2020 /// </summary>
2121 private readonly Encoding _originalOutputEncoding ;
2222
@@ -67,6 +67,10 @@ public Terminal()
6767 _originalOutputEncoding = Console . OutputEncoding ;
6868 Console . OutputEncoding = Encoding . UTF8 ;
6969
70+ // Capture the TextWriter AFTER setting the encoding, because setting
71+ // the encoding creates a new TextWriter in the Console class, but it's
72+ // possible to hang on to the old one (with the wrong encoding) and emit
73+ // garbage, as in https://github.com/dotnet/msbuild/issues/9030.
7074 Output = Console . Out ;
7175 }
7276
You can’t perform that action at this time.
0 commit comments