How to write colored text in Visual Studio output window from C #?

I want to write colored text in a Visual Studio output window from C #. I want to derive red code from my unit tests.

+4
source share
4 answers

In fact, there are extensions for this. I am using the Lite (free) version of VSCommands for Visual Studio 2010 . With the Pro version, you could create a regular expression to create coloring. In the lite version, I add β€œwarning” text to the debug message, and it is written in light brown.

+2
source

As far as I know, the output window in Visual Studio is an element of the "plain text box" type that does not support colored text.

+1
source

As far as I know, you cannot do this. You can change the color of the console font, but it does not affect the Visual Studio output window.

The only way to change the text color is through Tools-> Options-> Fonts and Colors, which affects all the text that is sent to the window.

+1
source
SetConsoleTextAttribute(hConsole, x) 

Where k is the integer color value and hConsole is the standard output descriptor.

More details here - simpler commands

-2
source

Source: https://habr.com/ru/post/1303827/


All Articles