Share via


Writing a custom MSBuild Logger for Team Build

While building using Team Build, the build process creates one log file (for compilation and code analysis errors and warnings) per platform-flavor for all solutions. However, few weeks back, while talking to a customer about Team Build, a new requirement came up. The customer wanted to have one log file per platform-flavor per solution. In his scenario, they had not ran code analysis before and turning that on was resulting in lots of errors/warnings all across the team project. He wanted to separate the warnings out into different log files per solution as the owners were different.

He asked me if this could be done. Well yes, anything for the customer!!!

Attached is the code for custom MSBuild logger that -

  1. Listens to build error and warning events and creates one log file per solution per platform-flavor. This is different from the standard Team Build logger, which creates one log per platform-flavor for all solutions.
  2. Each log file contains all the compilation and code analysis errors/warnings in that solution. 
  3. The log files created are copied to the drop location along with the other log files created by standard Team Build logger.

Using this logger is easy -

  1. Build the attached project and checkin the CustomTeamBuildLogger.dll to the build type folder i.e. same location as the TFSBuild.proj.
  2. Modify and add following to the TFSBuild.rsp file:
    /logger:Microsoft.TeamFoundation.Build.Samples.CustomTeamBuildLogger,CustomTeamBuildLogger.dll

This is just one example of ease with which one can extend MSBuild and Team Build. If you are interested in writing custom logger, you will find following posts useful -

https://blogs.msdn.com/msbuild/archive/2005/10/10/479223.aspx

https://blogs.msdn.com/msbuild/archive/2005/11/22/495322.aspx

https://blogs.msdn.com/chaitanyacheruvu/archive/2005/09/13/464611.aspx

Thanks!

CustomTeamBuildLogger.zip

Comments

  • Anonymous
    April 20, 2006
    Gautam Goenka blogs about building .NET 1.1 applications using Team Build and how to write a custom msbuild...
  • Anonymous
    April 04, 2007
    Most of the magic in a Team Build is done using either (a) customized tasks, or (b) a customized logger