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

TerminalLogger.WrapText: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. #11213

Open
metoule opened this issue Jan 3, 2025 · 0 comments

Comments

@metoule
Copy link

metoule commented Jan 3, 2025

Issue Description

On a dotnet test run on our CI, we get the following exception:

MSBUILD : error MSB4017: The build stopped unexpectedly because of an unexpected logger failure.
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
   at Microsoft.Build.Logging.TerminalLogger.TerminalLogger.WrapText(StringBuilder sb, String text, Int32 maxLength, String indent)
   at Microsoft.Build.Logging.TerminalLogger.TerminalLogger.FormatEventMessage(String category, String subcategory, String message, String code, String file, Int32 lineNumber, Int32 endLineNumber, Int32 columnNumber, Int32 endColumnNumber, String indent)
   at Microsoft.Build.Logging.TerminalLogger.TerminalLogger.FormatErrorMessage(BuildErrorEventArgs e, String indent)
   at Microsoft.Build.Logging.TerminalLogger.TerminalLogger.ErrorRaised(Object sender, BuildErrorEventArgs e)
   at Microsoft.Build.BackEnd.Logging.EventSourceSink.RaiseErrorEvent(Object sender, BuildErrorEventArgs buildEvent)

Steps to Reproduce

Steps to reproduce:

  1. Use the attached project (it's a single csproj which output a multiline text) ConsoleApp1.zip
  2. Use cmd.exe to be able to change the terminal width
  3. Change the terminal size via the mode command: mode 2,50
  4. Run dotnet build to build the attached project
  5. 💥

Expected Behavior

MSBuild should not throw an exception.

Actual Behavior

MSBuild throws the following exception:

MSBUILD : error MSB4017: The build stopped unexpectedly because of an unexpected logger failure.
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
   at Microsoft.Build.Logging.TerminalLogger.TerminalLogger.WrapText(StringBuilder sb, String text, Int32 maxLength, String indent)
   at Microsoft.Build.Logging.TerminalLogger.TerminalLogger.FormatEventMessage(String category, String subcategory, String message, String code, String file, Int32 lineNumber, Int32 endLineNumber, Int32 columnNumber, Int32 endColumnNumber, String indent)
   at Microsoft.Build.Logging.TerminalLogger.TerminalLogger.FormatErrorMessage(BuildErrorEventArgs e, String indent)
   at Microsoft.Build.Logging.TerminalLogger.TerminalLogger.ErrorRaised(Object sender, BuildErrorEventArgs e)
   at Microsoft.Build.BackEnd.Logging.EventSourceSink.RaiseErrorEvent(Object sender, BuildErrorEventArgs buildEvent)

Analysis

Looking at the code for TerminalLogger.WrapText, the only possible cause is that the Terminal width is smaller than the indentation. I'm not sure how that happens on our CI, but in any case the TerminalLogger should be robust to this situation.

Versions & Configurations

$ dotnet --version
9.0.101

$ msbuild --version
MSBuild version 17.12.12+1cce77968 for .NET Framework
17.12.12.57101

Similar issues

I found #8913 which looks similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant