Posted by Dan Rigsby on 18th August 2006
A while back I came across an excellent article from Robin Curry about integrating SourceMonitor into CruiseControl.Net using NAnt. I wanted this for my team as well. We use CruiseControl.Net, but have converted to the MSBuild camp. So I started to look into what it would take to get SourceMonitor running with MSBuild. I figured it would be easy, but I was amazed at just how easy it was.
The steps to integrate this are as follows:
- Download SourceMonitor and add it to the path.
- Write a project file for MSBuild. (I have included a sample in this article that should work for everyone, or at least can be used as a template for modifications)
- Add the file merge to the CruiseControl.Net ccnet.config file. (A sample is included in this article as well)
Here is the MSBuild file, we just called it SourceMonitor.csproj:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- SourceMonitor Properties"/" -->
<SourceMonitorDir>$(MSBuildProjectDirectory)\</SourceMonitorDir> <!-- be sure to end directory with a "/" -->
<?xml version="1.0" encoding="UTF-8" ?>
<Target Name="Clean" Condition=" '$(BUILDMACHINE)' != '' ">
<Exec Command="del $(SourceMonitorSummary)" />
<Exec Command="del $(SourceMonitorDetails)" />
<Target Name="Build" Condition=" '$(BUILDMACHINE)' != '' ">
<Exec Command="sourcemonitor.exe /C $(SourceMonitorInput)" />
Note that the <SourceMonitorDir> tag is to contain the directory where the *.cs files can be found. I currently have this set as the MSBuildProjectDirectory and have <include_subdirectories> set to true. You may wish to modify this.
And here is a sample of how to modify the ccnet.config file:
… Insert your msbuild solution information here. The SourceMonior.csproj file should be included in this solution …
<file>… Path …\SourceMonitorSummary.xml</file>
<file>… Path …\SourceMonitorDetails.xml</file>