Disabling or changing output colors used by the command line (tf.exe)


In the forum, a user asked how to turn off the colors used in the output of the version control command line for Team Foundation (tf.exe).  I thought I'd repost it here.

Question

When tf.exe (beta 3 refresh version) displays an error message the text is colored in yellow on black. My command prompt windows usually have black text on white background. Is it possible to let tf. exe display all output without changing the color, e.g. via an environment variable?

Answer

You can change or turn off the coloring by changing the settings in tf.exe.config (in the same location as tf.exe).

Here is the list of display settings.

Display.FallbackWidth - the width the command line uses when the output is not going to the console; this is used in column calculations, separators and defaults to 80
Display.DisableColors - turns colors on or off (defaults to true)
Display.ErrorBackground - the background of error or warning text (defaults to black)
Display.ErrorForeground - the foreground of error or warning text (defaults to yellow)
Display.InfoBackground - the background of informational text (defaults to black)
Display.InfoForeground - the foreground of informational text (defaults to cyan)

You can turn off coloring altogether by adding the following to your tf.exe.config file.

   <appSettings>
      <add key="Display.DisableColors" value="true" />
   </appSettings>

If you simply want to alter the coloring to make it look better, you could use something like the following.  The color choices are black, blue, cyan, darkblue, darkcyan, darkgray, darkgreen, darkmagenta, dark red, darkyellow, gray, green, magenta, red, white, and yellow.

   <appSettings>
      <add key="Display.ErrorForeground" value="blue" />
      <add key="Display.ErrorBackground" value="white" />
   </appSettings>

Your tf.exe.config file will end up looking something like the following.

<?xml version="1.0"?>
<configuration>
  <runtime>
    <gcConcurrent enabled="true" />
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <publisherPolicy apply="yes" />
      <probing privatePath="PrivateAssemblies" />
    </assemblyBinding>
  </runtime>

  <appSettings>
    <add key="Display.DisableColors" value="true" />
  </appSettings>

</configuration>

[Update 1/7] Fixed formatting issues.

Comments (2)

  1. BryanK says:

    Using TF.exe with TF2008, some messages are output as Red (errors) and some are Yellow (warnings).  There are also informational messages in Cyan.  What distinguishes the errors from the warnings?  The exit code from TF.exe is the same (1 or 100).  I call TF.exe from a custom tool and want to show the user the errors, but not the warnings, and can’t figure out how TF.exe is distinguishing the difference.

  2. buckh says:

    When you get only warnings, you should not get exit code 100, which indicates failure.  An exit code of 1 means that some things failed and some succeeded (e.g., you tried to check out two files, and one check out succeeded while the other failed).

    With respect to filtering the output, there is no reliable way to distinguish a warning from an error.

    Buck

Skip to main content