5
votes

Short:
How can I get colors for MSBuild running from Jenkins.

Long:
I have a nice Python build script that uses the pyColors module to print pretty output to console. When I'm running the script from CMD, I get colors from my script and colors from MSBuild (Ex: Blue color for "Done Building Project", Green for "Build succeeded", Red for errors).
I also run the same script from Jenkins (on Windows, of course). At the begging I got no colors in the Jenkins log (Console output). I then, installed the ANSIColor plugin, and now I only get the colors generated by the Python script, but no colors from MSBuild.
I tried to investigate it from the MSBuild project on GitHub, and I found that MSBuild has some safety try/ctach check on setting colors, that is probably failing (BaseConsoleLogger.cs line 455). I think that the Python module is simply printing raw ANSI escape characters, while the Win32 API for setting colors is failing when the console output is redirected.

P.S.
I'm using fully updated Jenkins on Windows 8 with Visual Studio 2015 SP1

1
Are you looking for something like the log parser plugin (wiki.jenkins-ci.org/display/JENKINS/Log+Parser+Plugin)?stijn
No. I'm looking for the original colors of MSBuild that are helpful in finding things in the output log. I am also using the Log Parser Plugin, but for other reasons.Pagefault
Well, I've opened a pull request for MSBuild on GitHub that could give me what I want link. Now I just need to hope they will merge it even though I didn't go through the process of creating an issue first.Pagefault
That was a fast rejection.Pagefault
That's too bad, your patch looked nice. Though I guess I understand they want a full motivation etc before adding new features to something like msbuild which is pretty widely used; but can't you make your changes into a custom msbuild logger and use that? I;ve used custom msbuild loggers before and it's a rethar easy yet powerful way to extend logging.stijn

1 Answers

5
votes

Big success, my pull request is now merged into the MSBuild project. https://github.com/Microsoft/msbuild/commit/58350c52d6e397fe90a7a48bcf46d4dda8023510 What I was looking for will be possible with the next release of Visual Studio using /forceConsoleColor