Just in case you are using TFS as a Source Control and Build Server, does not exclude you from using NUnit and NCover.
First we need a MSBuild task for running NCover: NCoverExplorer.Extras-1.4.0.5.zip
Extract the "NCoverExplorer.MSBuildTasks.dll" file to the folder where the "TFSBuild.proj" is located. Add the file to TFS Source Control, and do a check-in.
Since the build server needs NUnit, NCover and NCoverExplorer they should be placed in a folder under source control like "Tools".
All that is left is to modify the modyfy the TFSBuild.proj file.
At the start.
<!-- Do not edit this --> <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets" /> <!-- Start add the NCover MS Build Tasks --> <UsingTask TaskName="NCoverExplorer.MSBuildTasks.NCoverExplorer" AssemblyFile="NCoverExplorer.MSBuildTasks.dll"/> <UsingTask TaskName="NCoverExplorer.MSBuildTasks.NCover" AssemblyFile="NCoverExplorer.MSBuildTasks.dll"/> <UsingTask TaskName="NCoverExplorer.MSBuildTasks.NUnitProject" AssemblyFile="NCoverExplorer.MSBuildTasks.dll"/> <!-- End add the NCover MS Build Tasks --> <ProjectExtensions>
And in the end
<Target Name="NCover"> <CreateProperty Value="%(ConfigurationToBuild.FlavorToBuild)">
<Output PropertyName="FlavorToBuildValue" TaskParameter="Value" /> </CreateProperty> <CreateItem Include="$(BinariesRoot)\**\*Tests.dll"> <Output TaskParameter="Include" ItemName="TestAssemblies" /> </CreateItem> <NCover ToolPath="$(BuildDirectory)\Sources\Tools\NCover\" WorkingDirectory="$(BinariesRoot)\$(FlavorToBuildValue)" CommandLineExe="$(BuildDirectory)\Sources\Tools\NUnit\nunit-console.exe" CommandLineArgs="@(TestAssemblies) /xml=$(DropLocation)\$(BuildNumber)\NUnit.xml /labels /nologo" CoverageFile="$(DropLocation)\$(BuildNumber)\release_test_results.xml" LogFile="$(DropLocation)\$(BuildNumber)\coverage.log" /> </Target> <Target Name="CreateNCoverReport"> <NCoverExplorer ToolPath="$(BuildDirectory)\Sources\Tools\NCoverExplorer\" ProjectName="$(TeamProject)" ReportType="ModuleClassFunctionSummary" OutputDir="$(DropLocation)\$(BuildNumber)\" XmlReportName="ncoverreport.xml" HtmlReportName="ncoverreport.html" ShowExcluded="False" SatisfactoryCoverage="80"
CoverageFiles="$(DropLocation)\$(BuildNumber)\release_test_results.xml" Exclusions="Assembly=*Tests" /> </Target> <Target Name="AfterCompile" DependsOnTargets="NCover;CreateNCoverReport"> <Message Text="AfterCompile target executed."> </Message> </Target>
In every build there should be a file called ncoverreport.html