Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes writing unwanted characters to console when TerminalLogger is created directly #10678

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
<Project>
<PropertyGroup>
<VersionPrefix>17.12.0</VersionPrefix>
<VersionPrefix>17.12.1</VersionPrefix>
<PackageValidationBaselineVersion>17.11.4</PackageValidationBaselineVersion>
<AssemblyVersion>15.1.0.0</AssemblyVersion>
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
Expand Down
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
Loading