NCover Documentation
Docs  ›  Legacy  ›  Reference  ›  MSBuild Tasks

Please visit Covering MSTest for updated information.

NCover provides MSBuild tasks for measuring and reporting on code coverage.

Including The Tasks

To use the NCover MSBuild tasks you will need to include them in your build file with the MSBuild UsingTask element:

  AssemblyFile="C:\Program Files\NCover\Build Task Plugins\NCover.MSBuildTasks.dll" />
  AssemblyFile="C:\Program Files\NCover\Build Task Plugins\NCover.MSBuildTasks.dll" />

The <NCover> Task

Use the <NCover> task to measure code coverage within your MSBuild based build.

Basic Usage

<Target Name="Coverage">
  <NCover ToolPath="C:\Program Files\NCover\"
      TestRunnerArgs="TestAssembly1.dll TestRunner2.dll"

The above task runs NCover on the NUnit console test runner, giving it two test assemblies as arguments, and writes the resulting output to the file Coverage.xml.


See the NCover.Console MSBuild Options for an exhaustive reference of the options available within the NCover MSBuild task.

The <NCoverReporting> Task

Use the <NCoverReporting< task to generate reports, merge coverage files, and fail builds based on coverage thresholds.

Basic Usage

<Target Name="CoverageReport">
  <NCoverReporting ToolPath="C:\Program Files\NCover\"

The example above sets up a property for the reports to generate and then uses the NCoverReporting task to load a coverage file and generate the report described in the property.


See the NCover.Reporting MSBuild Options for an exhaustive reference of the options available with the NCoverReporting MSBuild task.

If you still need technical assistance, we can help:

Submit A Support Ticket