msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

[Feature Request]: Stop splitting long text into lines

Open hez2010 opened this issue 1 year ago • 9 comments

Summary

Stop splitting long text into lines.

Background and Motivation

This feature has more problems than benefits.

  • It never works properly on non-English logs, because non-ascii characters usually takes more width than ascii characters, which results in worse output.
  • It can break up a character from the middle and causes garbled result.
  • It makes it hard to copy commands printed to the log for user, as the user will have to remove those spaces and additional lines manually.

Proposed Feature

Remove this feature.

Alternative Designs

No response

hez2010 avatar Aug 28 '24 15:08 hez2010

Thanks for reporting - can you give us a screenshot or copy/paste of a situation where splitting is happening? Your current report is too general for us to understand where to start looking.

baronfel avatar Aug 28 '24 15:08 baronfel

Sure. You can see how the current output be like on a Japanese system:

image

Focusing on lines

をご覧ください [D:\sour
ce\repos\Test\HelloWorld\HelloWorld.csproj]

You can see due to the width difference between ascii and non-ascii characters, the result becomes worse than not splitting it.

Also, if there's any rich text in the output, characters can be splitted from the middle which causes garbled result like this (see the ��):

image

hez2010 avatar Aug 28 '24 15:08 hez2010

Here is a project file for you to reproduce:

<Project>
  <Target Name="Build">
    <Message Text="😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄" Importance="high" />
    <Message Text="これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test." Importance="high" />
  </Target>
</Project>

To repro, build it without enabling terminal logger.

image

hez2010 avatar Aug 28 '24 15:08 hez2010

Thank you! This is very helpful feedback.

baronfel avatar Aug 28 '24 15:08 baronfel

Making sure I understand @hez2010 - from my local testing and what you've said above, I believe that Terminal Logger correctly line-wraps the messages. Is that correct? So this bug is present only in the older console logger?

baronfel avatar Aug 28 '24 16:08 baronfel

So this bug is present only in the older console logger?

Yes, the new terminal logger doesn't split texts so it doesn't have this issue. The older console logger is still necessary because the new terminal logger omits all outputs from native toolchains which are sometimes useful. I suggest removing the text splitting behavior in the old console logger.

hez2010 avatar Aug 28 '24 16:08 hez2010

This might be caused by MSBuild trying to align the text width with the console window. You can disable the line wrapping in the console logger with the ForceNoAlign option of the consoleLoggerParameters parameter:

  -consoleLoggerParameters:<parameters>
                     Parameters to console logger. (Short form: -clp)
                     The available parameters are:
                        PerformanceSummary--Show time spent in tasks, targets
                            and projects.
                        Summary--Show error and warning summary at the end.
                        NoSummary--Don't show error and warning summary at the
                            end.
                        ErrorsOnly--Show only errors.
                        WarningsOnly--Show only warnings.
                        NoItemAndPropertyList--Don't show list of items and
                            properties at the start of each project build.
                        ShowCommandLine--Show TaskCommandLineEvent messages
                        ShowTimestamp--Display the Timestamp as a prefix to any
                            message.
                        ShowEventId--Show eventId for started events, finished
                            events, and messages
                        ForceNoAlign--Does not align the text to the size of
                            the console buffer
                        DisableConsoleColor--Use the default console colors
                            for all logging messages.
                        DisableMPLogging-- Disable the multiprocessor
                            logging style of output when running in
                            non-multiprocessor mode.
                        EnableMPLogging--Enable the multiprocessor logging
                            style even when running in non-multiprocessor
                            mode. This logging style is on by default.
                        ForceConsoleColor--Use ANSI console colors even if
                            console does not support it
                        PreferConsoleColor--Use ANSI console colors only if
                            target console does support it
                     Verbosity--overrides the -verbosity setting for this
                            logger.
                     Example:
                        -consoleLoggerParameters:PerformanceSummary;NoSummary;
                                                 Verbosity=minimal

for example:

dotnet build -consoleLoggerParameters:Verbosity=Minimal;ForceNoAlign;Summary

You can also add a Directory.Build.rsp file to your repository to have MSBuild automatically pick up the command-line argument: https://github.com/jeffkl/EnvironmentAbstractions/blob/main/Directory.Build.rsp#L2

jeffkl avatar Aug 28 '24 16:08 jeffkl

ForceNoAlign did fix the problem using the test project that @hez2010 included:

chusk@Chet-Desktop > ./msbuild-logger-linebreaks > dotnet build /t:Build -tl:off --consoleLoggerParameters:ForceNoAlign
  😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄 😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄
  これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test.これはテストです。This is a test. これはテストです。This is a test.これはテストです。This is a test.

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.07

baronfel avatar Aug 28 '24 16:08 baronfel

Can we make ForceNoAlign default? The alignment here makes no sense to me, it's buggy and just making things worse.

hez2010 avatar Aug 28 '24 16:08 hez2010