Find file
Fetching contributors…
Cannot retrieve contributors at this time
98 lines (86 sloc) 3.73 KB

Gendarme MSBuild Task

This is a simple MSBuild wrapper for Gendarme.


Download and install Gendarme


First, download the latest binary.


To call from an MSBuild project, the syntax is straightforward:

<Project DefaultTargets="Test" xmlns="">
    <UsingTask AssemblyFile="Path\To\GendarmeMsBuild.dll" TaskName="GendarmeMsBuild.Gendarme" />
    <Target Name="Test">

Visual Studio

You can also integrate with Visual Studio, so that Gendarme is run as part of building your project. Simply add the following to the bottom of your .csproj file (just before the </Project> tag):

<UsingTask AssemblyFile="Path\To\GendarmeMsBuild.dll" TaskName="GendarmeMsBuild.Gendarme"/>
<Target Name="AfterBuild">
    <Gendarme Assemblies="$(TargetPath)" IntegrateWithVisualStudio="True"/>

This should give you something like this:

Visual Studio screenshot


The following properties are supported on the task:

GendarmeExeFilename The path to Gendarme.exe. Defaults to C:\program Files\gendarme\gendarme.exe (or C:\program files (x86)\gendarme\gendarme.exe on 64bit systems) if no value is supplied.
Assemblies The assemblies to inspect. Multiple files and masks ('?', '*') are supported. Required.
GendarmeConfigFilename The path to the Gendarme config file. Maps to --config [filename] (optional)
Ruleset The name of the ruleset to be used. Maps to --ruleset [set] (optional)
GendarmeIgnoreFilename The path to the Gendarme ignore file. Maps to --ignore [filename] (optional)
Severity The inspection severity. Maps to --severity [all | audit[+] | low[+|-] | medium[+|-] | high[+|-] | critical[-]] (optional)
Confidence The confidence level defects are filtered by. Maps to --confidence [all | low[+] | normal[+|-] | high[+|-] | total[-]] (optional)
Limit Limit the amount of defects found. Maps to --limit [value] (optional)
OutputXmlFilename The path to save Gendarme's output XML (optional)
Quiet Output minimal info. Maps to --quiet. Also causes the MSBuild task to output no info (optional). Ignored when Visual Studio integration is enabled
Verbose Output verbose info. Maps to --verbose (optional). Ignored when Visual Studio integration is enabled
WarningsAsErrors Whether to consider defects (which are normally treated as warnings) as errors. When set to True, the build will fail if any defects are found. Defaults to False (optional)
IntegrateWithVisualStudio Whether or not to format the output in a format Visual Studio can understand. Defaults to false (optional)


The code is released under the MIT X11 license - see the LICENSE file for the full license text.


The Gendarme team for building such a useful and flexible tool. Lex Li for useful feedback.