Skip to content

Commit

Permalink
Fixes writing unwanted characters to console when TerminalLogger is c…
Browse files Browse the repository at this point in the history
…reated directly (#10678)

Call method that tells Windows to allow VT-100 output processing whenever the TerminalLogger is instantiated, rather than only in the MSBuild CLI entrypoint `xmake.cs`.

Fixes #10579.
  • Loading branch information
MichalPavlik authored Sep 19, 2024
1 parent 1205246 commit fea15fb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/MSBuild/TerminalLogger/TerminalLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ public ProjectContext(BuildEventContext context)
/// </summary>
private bool _showCommandLine = false;

private uint? _originalConsoleMode;

/// <summary>
/// Default constructor, used by the MSBuild logger infra.
/// </summary>
Expand Down Expand Up @@ -263,6 +265,8 @@ public void Initialize(IEventSource eventSource, int nodeCount)
/// <inheritdoc/>
public void Initialize(IEventSource eventSource)
{
(_, _, _originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes();

ParseParameters();

eventSource.BuildStarted += BuildStarted;
Expand Down Expand Up @@ -358,6 +362,8 @@ private bool TryApplyShowCommandLineParameter(string? parameterValue)
/// <inheritdoc/>
public void Shutdown()
{
NativeMethodsShared.RestoreConsoleMode(_originalConsoleMode);

_cts.Cancel();
_refresher?.Join();
Terminal.Dispose();
Expand Down

0 comments on commit fea15fb

Please sign in to comment.