Open danpere opened 1 week ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
This is being fixed as https://github.com/dotnet/msbuild/issues/10998.
.NET SDK 9.0.1xx (I guess 9.0.101) is changed not to use TerminalLogger in that situation:
For .NET SDK 9.0.2xx, there is a more complex fix pending, which lets MSBuild choose ConsoleLogger or TerminalLogger, but it needs a Visual Studio update too:
Describe the bug
dotnet run > some_file
should output only the output of the program being run tosome_file
. That is the behavior of .NET SDK 8. .NET SDK 9 instead prefixes that output with.]9;4;3;.\.]9;4;0;.\
(hex1b5d 393b 343b 333b 1b5c 1b5d 393b 343b 303b 1b5c
), the Windows Terminal ANSI escape sequence for "set progress indicator to indeterminate, then clear progress indicator". This breaks essentially any script that redirects the output ofdotnet run
and performs any kind of analysis on it.To Reproduce
Then examine those files with
xxd
(required becausecat
ing ANSI escape sequences to the console won't display them):While the second one is expected to have escape sequences, observe that the first one does as well. Here's the output on both .NET 8 and .NET 9:
.NET 9 using
>
redirect (bad).NET 8 using
>
redirect (expected)And for reference, here's the output using
script
. Note that the output is not identical, so clearlydotnet run
is detecting that its output is being redirected, but maybe that isn't getting to all of the code outputting to the console?.NET 9 using
script
.NET 8 using
script
Other bugs referencing this issue
Searching for existing issues about this, I found #44442 which appears to possibly be a workaround for this same bug. There's also dotnet/msbuild#10678, which appears to be a fix for this bug... but that PR merged a while ago, and the bug is still happening.
Exceptions (if any)
N/A
Further technical details
dotnet --info
While the actual bug was originally encountered on Windows, this repro was done under Linux as it was easier to deal with the terminal manipulation details there. Specifically, all of this was done from the WSL command line, running Ubuntu 22.04: