MSBuild in Visual Studio Part 13: The Three Custom Loggers

We’re written in the past about how to write custom loggers, and you probably won’t be surprised to learn that Visual Studio makes use of custom loggers when interacting with MSBuild. There are three separate loggers, each with its own purpose.

The project load logger is used when projects are opened. It discards all messages logged while the project is opened, puts warnings in the error list, and displays any errors in a message box to the user. The errors displayed are quite detailed and useful in helping diagnose project file formatting issues.

The design-time compiler initialization logger is used when Visual Studio invokes the Compile target at design time. It discards all messages, and places all warnings and errors in the error list. The build logger is used when a build is kicked off from within Visual Studio. Messages are sent to the output window, and warnings and errors go to both the output window and the error list. Here's what the errors and warnings from these two loggers look like:

Each of these loggers is based on the ConsoleLogger since we didn’t want to re-write all the formatting that the ConsoleLogger does.

One hole in our logging story in Visual Studio 2005 is that the in-proc compilers don’t actually log through the MSBuild logging mechanism. They log their output directly to the output window and error list. While this isn’t a major issue, we’d like to change this next time around so everything goes through the same pipeline.

[ Author: Neil Enns ]