CruiseControl.Net, MSBuild, and SourceMonitor
Posted by Dan Rigsby on August 18th, 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"/" -->
<PropertyGroup>
<SourceMonitorInput>SourceMonitor.xml</SourceMonitorInput>
<SourceMonitorProject>SourceMonitorProject.smp</SourceMonitorProject>
<SourceMonitorDir>$(MSBuildProjectDirectory)\</SourceMonitorDir> <!-- be sure to end directory with a "/" -->
<SourceMonitorSummary>SourceMonitorSummary.xml</SourceMonitorSummary>
<SourceMonitorDetails>SourceMonitorDetails.xml</SourceMonitorDetails>
<SourceMonitorCheckPointName>BaseLine</SourceMonitorCheckPointName>
<SourceMonitorText> <![CDATA[
<?xml version="1.0" encoding="UTF-8" ?>
<sourcemonitor_commands>
<write_log>true</write_log>
<command>
<project_file>$(SourceMonitorProject)</project_file>
<project_language>CSharp</project_language>
<source_directory>$(SourceMonitorDir)</source_directory>
<include_subdirectories>true</include_subdirectories>
<ignore_headers_footers>true</ignore_headers_footers>
<checkpoint_name>$(SourceMonitorCheckPointName)</checkpoint_name>
<export>
<export_file>$(SourceMonitorSummary)</export_file>
<export_type>1</export_type>
</export>
</command>
<command>
<project_file>$(SourceMonitorProject)</project_file>
<checkpoint_name>$(SourceMonitorCheckPointName)</checkpoint_name>
<export>
<export_file>$(SourceMonitorDetails)</export_file>
<export_type>2</export_type>
</export>
</command>
</sourcemonitor_commands>
]]></SourceMonitorText>
</PropertyGroup>
Â
<Target Name="Clean" Condition=" '$(BUILDMACHINE)' != '' ">
<Exec Command="del $(SourceMonitorSummary)" />
<Exec Command="del $(SourceMonitorDetails)" />
</Target>
<Target Name="Build" Condition=" '$(BUILDMACHINE)' != '' ">
<WriteLinesToFile
File="$(SourceMonitorInput)"
Lines="$(SourceMonitorText)"
Overwrite="true" />
<Exec Command="sourcemonitor.exe /C $(SourceMonitorInput)" />
</Target>
</Project>
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:
<tasks>
<msbuild>
… Insert your msbuild solution information here. The SourceMonior.csproj file should be included in this solution …
</msbuild>
<merge>
<files>
<file>… Path …\SourceMonitorSummary.xml</file>
<file>… Path …\SourceMonitorDetails.xml</file>
</files>
</merge>
</tasks>











January 11th, 2008 at 6:51 pm
Thanks for information.
many interesting things
Celpjefscylc