Integrating FxCop into CruiseControl.NET
I am not a fan of this technology and I would probably steer away from using this in future projects.
There are three steps in setting up, configuring and viewing the results of FxCop within your Continuous Integration process.
STEP 1
Add a CruiseControl.NET task in your ccnet.config file
<project name="FxCop">
<labeller type="defaultlabeller" />
<webURL>http://localhost/ccnet/ViewFarmReport.aspx</webURL>
<sourcecontrol type="filtered">
<sourceControlProvider type="svn" autoGetSource="true">
<executable>C:\Program Files\VisualSVN Server\bin\svn.exe</executable>
<trunkUrl>http://domain.com/svn/ProjectName/trunk</trunkUrl>
<workingDirectory>D:\Projects\compile\ProjectName\trunk</workingDirectory>
<tagOnSuccess>false</tagOnSuccess>
<tagBaseUrl>http://domain.com/svn/ProjectName/tags</tagBaseUrl>
<username>rmartin</username>
<password>*******</password>
</sourceControlProvider>
<inclusionFilters>
<pathFilter>
<pattern>**/*.*</pattern>
</pathFilter>
</inclusionFilters>
</sourcecontrol>
<tasks>
<exec>
<executable>C:\Program Files\Microsoft FxCop 1.36\FxCopCmd.exe</executable>
<baseDirectory>D:\Projects\compile\ProjectName\trunk\source\</baseDirectory>
<buildArgs>
/p:"d:\Projects\compile\ProjectName\trunk\Build\rules.FxCop"
/out:"c:\Program Files\CruiseControl.NET\server\FxCop\Artifacts\results.xml" /gac
</buildArgs>
<buildTimeoutSeconds>300</buildTimeoutSeconds>
</exec>
</tasks>
<publishers>
<merge>
<files>
<file>c:\Program Files\CruiseControl.NET\server\FxCop\Artifacts\results.xml</file>
</files>
</merge>
<xmllogger />
<statistics />
<email
from="ProjectNameBuild@domain.com"
mailhost="mail.domain.com" includeDetails="TRUE">
<users>
<user name="Ryan Martin" group="buildmaster" address="rmartin@domain.com"/>
</users>
<groups>
<group name="buildmaster" notification="always"/>
</groups>
</email>
</publishers>
</project>
STEP 2
Add a task in your NAnt build script
<?xml version="1.0" encoding="utf-8"?>
<project name="ProjectNameWeb" default="build" xmlns="http://nant.sf.net/release/0.85/nant.xsd">
<!-- Properties -->
<property name="fxcop.output.dir" value="${build.output.dir}\FxCopOutput" />
<property name="fxcopcmd.exe" value="C:\Program Files\Microsoft FxCop 1.36\fxcopcmd.exe" />
<property name="rules.fxcop" value="rules.fxcop" />
<property name="fxcop.xml" value="${fxcop.output.dir}\fxcop.xml" />
<!-- Called Externally -->
<target name="build" depends="compile" />
<target name="fxcop" depends="compile, reporting" />
<!-- Coding Tasks -->
<target name="reporting" depends="compile">
<exec program="${fxcopcmd.exe}" commandline="/p:${rules.fxcop} /o:${fxcop.xml}" failonerror="false"/>
</target>
</project>
STEP 3
Go to your CruiseControl.NET Web Dashboard to run and view the results from FxCop
Click the FORCE button for the FxCop task and review the results it generates
NOT WORTH IT IN MY OPINION, RESHARPER DOES A LOT OF THE SAME FUNCTIONALITY IN REAL TIME