dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.24k stars 1.35k forks source link

[Feature Request]: Stop splitting long text into lines #10578

Open hez2010 opened 3 months ago

hez2010 commented 3 months ago

Summary

Stop splitting long text into lines.

Background and Motivation

This feature has more problems than benefits.

Proposed Feature

Remove this feature.

Alternative Designs

No response

baronfel commented 3 months ago

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.

hez2010 commented 3 months ago

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 commented 3 months ago

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

baronfel commented 3 months ago

Thank you! This is very helpful feedback.

baronfel commented 3 months ago

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?

hez2010 commented 3 months ago

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.

jeffkl commented 3 months ago

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

baronfel commented 3 months ago

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
hez2010 commented 3 months ago

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