-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
MSBuild changes console colors when logging to a file #1792
Comments
Severity: this is causing builds to fail because it overflows Travis's maximum logfile size. |
Possibly related to #505? @natemcmaster can you try setting |
Yes, that is the workaround @dougbu is working on |
As long as https://github.com/aspnet/KoreBuild/archive/dev.zip wasn't lagging (definitely up-to-date now), this workaround isn't working. For example https://api.travis-ci.org/jobs/207448561 was started about 5 minutes ago and I checked in the workaround almost half an hour ago. Despite local testing to confirm colours aren't used when Any other suggestions? If the ANSI stuff isn't coming from MsBuild, gotta wonder why we're hitting the Travis 4MB log limit. |
FYI the workaround relies on the environment variables Travis always sets. See https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables I'll run a test in a smaller repo to make sure that page is correct. |
My workaround is doing what it's designed to do. But, Skip to the bottom of https://travis-ci.org/aspnet/Antiforgery/jobs/207457375 to see the response files we're using when invoking MsBuild. Nonetheless https://api.travis-ci.org/jobs/207457375/log.txt and https://api.travis-ci.org/jobs/207457376/log.txt are really big. A few commands have a few ANSI codes in their output. But, the loads of colour coding happen only with the |
We're using the I'm curious how #505 could be related? That PR was merged nearly a year ago. |
- piping MsBuild output into `tee` cleans up the excess ANSI character codes Extend the related `/clp:DisableConsoleColor` fix in fc6f034 to Windows CI machines.
- piping MsBuild output into `tee` cleans up the excess ANSI character codes Extend the related `/clp:DisableConsoleColor` fix in fc6f034 to Windows CI machines.
Found a workaround that actually works: Piping What is going on here? Are the excess characters coming from something in MsBuild that |
- piping MsBuild output into `tee` cleans up the excess ANSI character codes - add `pipefail` option setting; ensure new pipeline doesn't cause false positives Extend the related `/clp:DisableConsoleColor` fix in fc6f034 to Windows CI machines.
This is very odd. There appear to be a combination of factors at play.
The first one is the real problem here. Tracking the second one as #1825. |
Because FileLogger used the default value of the SetColor and ResetColor delegates, it was quietly changing and resetting console color for every log message that was considered by the FileLogger. On Windows, this was unnecessary but not too noticeable. On Unix systems, though, console colors are set by emitting an escape code to the output stream, so this became observable. Explicitly passing the Dont* mechanisms to prevent the unnecessary work from happening. I removed the null check for the `write` delegate from ConsoleLogger's constructor because it seemed cleaner to set the delegate to `null` from FileLogger than to explicitly specify the default `Console.Out.Write`. Fixes dotnet#1792.
Naturally, the reason for this ridiculous behavior is ridiculous: |
Naturally 😺 |
Because FileLogger used the default value of the SetColor and ResetColor delegates, it was quietly changing and resetting console color for every log message that was considered by the FileLogger. On Windows, this was unnecessary but not too noticeable. On Unix systems, though, console colors are set by emitting an escape code to the output stream, so this became observable. Explicitly passing the Dont* mechanisms to prevent the unnecessary work from happening. I removed the null check for the `write` delegate from ConsoleLogger's constructor because it seemed cleaner to set the delegate to `null` from FileLogger than to explicitly specify the default `Console.Out.Write`. Fixes #1792.
We started running into build failures on Travis CI using MSBuild. It appears the logger produces thousands of unnecessary ANSI color codes.
Example:
https://travis-ci.org/aspnet/DotNetTools/jobs/206846997
The log output appears normal:
But if you look at the raw log file, you'll see that hundreds of color codes have been logged.
https://s3.amazonaws.com/archive.travis-ci.org/jobs/206846997/log.txt
cc @dougbu
The text was updated successfully, but these errors were encountered: