Skip to content

Commit

Permalink
Fix the crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
AR-May committed May 22, 2024
1 parent 9e21c71 commit 4f51227
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/MSBuild/TerminalLogger/Terminal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ public void WriteColorLine(TerminalColor color, string text)
/// <inheritdoc/>
public void Dispose()
{
Console.OutputEncoding = _originalOutputEncoding;
try
{
Console.OutputEncoding = _originalOutputEncoding;
}
catch
{
// In some terminal emulators setting back the previous console output encoding fails.
// See https://github.com/dotnet/msbuild/issues/9662.
// We do not want to throw an exception if it happens, since it is a non-essentual failure in the logger.
}
}
}

0 comments on commit 4f51227

Please sign in to comment.