Szymon Kobalczyk's Blog

A Developer's Notebook

  Home  |   Contact  |   Syndication    |   Login
  106 Posts | 6 Stories | 584 Comments | 365 Trackbacks


View Szymon Kobalczyk's profile on LinkedIn

Tag Cloud


Blogs I Read

Tools I Use

Updated: This project now has its own page.

I use CruiseControl.NET with MSBuild for automated build of a .NET 2.0 project. You can find instructions how to setup this in Michael Swanson's Blog. Everything works fine but one thing that bothered me was that CC.NET logged raw console output from MSBuild, whereas I wanted the results as structured XML document so it can be nicely integrated into the build report and formatted with XSL. What I needed was an XML Logger for MSBuild.

I first found one written by Wilco Bauwer but didn't liked that way it logged the build events (as plain list of events losing the hierarchy of the build process) but it helped me a lot to get started. Besides the log files were really huge. This made me to write one myself. I've posted the first version working with .NET 2.0 Beta 1 to the CC.NET JIRA. In Beta 2 you can notice that console output is colored but I still haven't found any XmlLogger as part of the Framework. But the MSBuild API changed slightly (now each type of build event has different signature) so here you can download the updated version.

To use it execute following command line:

MSBuild.exe yourproject.sln /logger:Kobush.Build.Logging.XmlLogger,Kobush.MSBuild.dll;buildresult.xml

You can also add following switches to prevent any console output:

/nologo /noconsolelogger

The output verbosity level can be specified using /verbosity parameter. I tried to make it produce the same output on various levels like from default console logger.

Updated: I've included two XSL files for CC.NET Web Dashboard that can format the build results. First one (compile-msbuild.xsl) adds new section on build summary page. To use it add following line in the dashboard\plugins\buildPlugins\buildReportBuildPlugin\xslFileNames section of the dashbard.config file:


Second one (msbuild.xsl) can be used to configure additional project report plug-in. Add following line in the dashboard\plugins\buildPlugins section:

Above configuration applies to latest CC.NET 0.9 but the files can be used with earlier versions.

I hope someone would find it useful and if you have any problems or suggestions just let me know.

posted on Friday, May 6, 2005 9:42 PM


# re: XmlLogger for MSBuild 6/28/2005 1:10 PM Sandra
I need to have build output for msBuild in, however I'm using a build.proj file and executing it via the command prompt using msBuild.ext
Can you use this with .proj files with the logger parameters? I'm doing the following and getting:

>MsBuild build.proj "/logger:Kobush.Build.Logging.XmlLogger, Kobush.MsBuild.dll;buildresult.xml"

It's stating it can't find an instance of the logger?

# re: XmlLogger for MSBuild 6/28/2005 1:22 PM Szymon
I just tried it on .csproj file and it works fine. Did you copy the Kobush.MsBuild.dll to your working directory? Also I don't think there should be a space after a collon in the logger option.

# re: XmlLogger for MSBuild 6/28/2005 2:51 PM Sandra
I didn't mean .csproj files, I'm using build.proj (msbuild project files) and passing it to the msbuild.exe. This .proj file has all the tasks, properties, items, etc... defined in it that is executed by msbuild.

# re: XmlLogger for MSBuild 6/28/2005 3:46 PM Sandra
Sorry if you were mistunderstood before, I should have been clearer.
Have you used msbuild.proj files before with this type of logger?

# re: XmlLogger for MSBuild 6/28/2005 3:58 PM Szymon
I've been using it with .sln files, .csproj files and with build files that I'v written myself. If msbuild compiles this without a logger then it shouldn't matter. Again, make sure you have the Kobush.MsBuild.dll in the same folder as your project build file and remove any spaces in the logger option. Also make sure that you have the same version of .NET framework (I compiled against Beta 2).

# re: XmlLogger for MSBuild 6/28/2005 4:06 PM Sandra
Ok thanks, I'll check that. I'm just upgrading to CCNet 9.2 as I was using 0.7.

# re: XmlLogger for MSBuild 6/28/2005 6:00 PM Sandra
Did you have any problems when upgrading to 0.9.2?
It's completely wrecked my build!

# re: XmlLogger for MSBuild 6/29/2005 12:15 PM Szymon
I just finished upgrading and everything went smoothly. One thing to remember is to back up all your configuration files, because they can get overwritten. I also moved the build working directory away from the server dir and saved build state file.

# re: XmlLogger for MSBuild 6/29/2005 12:18 PM Sandra
Could you help?
I've basically just ran the setup.exe for 0.9.2 which installed the service, ctray and webdashboard. As everything was setup previously for 0.7 I had to need to configure anything really, just insert my ccnet.config file and start the service, however I'm getting errors galour?
What was the process you took to upgrade, maybe I've missed something.
Sorry about all the questions.

# re: XmlLogger for MSBuild 6/29/2005 1:02 PM Szymon
There were some changes in the config file format when CCNET 9 came out. Put your mail in the URL field here so I can contact you directly.

# re: XmlLogger for MSBuild 6/29/2005 1:10 PM Sandra
I've just sorted it, it was the config file, can you believe it! They should have put it on their website. Errors were put in the eventlog.

I'm just going to get it in a stable state and then I'll try and hookup you're logger so I can get build output to the site.
Thanks for you're help so far, no doubt I'll be intouch in a bit!

# re: XmlLogger for MSBuild 6/29/2005 4:57 PM Sandra
It won't work when have the following in CCNet build task for msbuild, I place it in the <buildArgs> item:
MsBuild build.proj /logger:Kobush.Build.Logging.XmlLogger, Kobush.MsBuild.dll;buildresult.xml

Do you think it will work if I place it in the actual build.proj file, under the tools.devenv task for the sln file?

# re: XmlLogger for MSBuild 6/29/2005 5:25 PM Sandra
In your logger, 'BuildFinishedEventArgs' is part of what namespace? Is it Microsoft.Build.Framework?

# re: XmlLogger for MSBuild 7/5/2005 11:11 AM Lynn
Do you have to put your plugin dll in 'bin' directory of web dashboard?

# re: XmlLogger for MSBuild 7/5/2005 11:21 AM Szymon
On my projects I just put it in the same directory with the build scripts. But I have settled to using NAnt for main build script and exec msbuild as one of the tasks. If you are calling msbuild directly from CCNet using exec task then you can specify a working directory there. Place the dll in that directory. Or you can add full path to the dll in the logger option after colon(e.g. /logger:Kobush.Build.Logging.XmlLogger,C:\Projects\Build\Kobush.MSBuild.dll).

# re: XmlLogger for MSBuild 7/5/2005 12:01 PM Lynn
Thanks for that. For the second xsl file, I've put the following in my dashboard config as the actionname, is this correct, as the description above you put it missing?

<xslReportBuildPlugin description=MsBuild Report actionName=MsBuildReport xslFileName=xslmsbuild.xsl />

# re: XmlLogger for MSBuild 7/5/2005 12:16 PM Szymon
You need to add quotes on the attribute values. I have it like this for the project report plug-in:

<xslReportBuildPlugin description="MSBuild Output" actionName="MSBuildOutputBuildReport" xslFileName="xsl\msbuild.xsl" />

For the build report plug-in I added this to existing section:


# re: XmlLogger for MSBuild 7/5/2005 4:31 PM Lynn
It's producing the buildresult.xml file, however when I view it in the web dashboard and select MSBuild Output i get an error stating 'Log does not contain any xml output from msbuild (use the argument:......)'???

# re: XmlLogger for MSBuild 7/5/2005 4:37 PM Szymon
You need to merge the buildresult.xml file into project build log. Use the merge task in the CCNet.config like this:


# re: XmlLogger for MSBuild 7/5/2005 4:56 PM Lynn
Yes I've done that too?

# How To: Write a custom logger for MSBuild 10/10/2005 10:28 AM MSBuild Team Blog
This question came across the internal conversion alias this morning:

Is there a way to send errors...

# re: XmlLogger for MSBuild 10/18/2005 12:08 PM Charles Crichton
I had to modify a XmlLogger.cs method to get it to work here in the en-GB culture. Ironically I've done this by hard-coding the en-US culture into the following method.

The DateTime.Parse method defaults to the local culture, but for some reason the timestamp is written out by the LogStageStarted method in the en-US culture.

My hacked up method now reads:

private void LogStageFinished(bool succeded, DateTime timeStamp)
if (currentElement.Name == XmlLoggerElements.Build || Verbosity == LoggerVerbosity.Diagnostic)
IFormatProvider culture = new CultureInfo("en-US");
DateTime startTime = DateTime.Parse(currentElement.GetAttribute(XmlLoggerAttributes.StartTime),culture);
SetAttribute(currentElement, timeStamp - startTime, XmlLoggerAttributes.ElapsedTime);

SetAttribute(currentElement, succeded, XmlLoggerAttributes.Success);

if (this.currentElement.ParentNode is XmlElement)
XmlElement parentElement = (XmlElement)this.currentElement.ParentNode;

// don't put element's that don't contain any messages
if (!currentElement.HasChildNodes && Verbosity != LoggerVerbosity.Detailed && Verbosity != LoggerVerbosity.Diagnostic)

this.currentElement = parentElement;

# re: XmlLogger for MSBuild 10/18/2005 12:15 PM Szymon
Thanks for your comment and fix. I intend to publish updated sources on ProjectDistributor as soon as I get the VS Final Release and verify everything works fine. There were also some fixes made by the CCNET team that I need to integrate back to my code.

# re: XmlLogger for MSBuild 1/11/2006 6:15 AM Morten Teinum
I think there is a bug...

private void SetAttribute(XmlElement element, object obj, string name)
{ ...

else if (t == typeof(TimeSpan))
// format TimeSpan to show only integral seconds
double seconds = ((TimeSpan)obj).Seconds;
TimeSpan whole = TimeSpan.FromSeconds(Math.Truncate(seconds));
element.SetAttribute(name, whole.ToString());



should be:


else you will always get a value in the range [0..59]

# re: XmlLogger for MSBuild 1/11/2006 10:22 AM Szymon
Thank you Mortan. I was planing to release the updated version for VS RTM. I should include your path, as well as few other and hopefully release it soon.

# re: XmlLogger for MSBuild 1/14/2006 10:14 AM Szymon
I've created separate page for this project including some usage instructions. Also the updated version was published (

Post A Comment