Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
README.markdown

Gendarme MSBuild Task

This is a simple MSBuild wrapper for Gendarme.

Prerequisites

Download and install Gendarme

Usage

First, download the latest binary.

MSBuild

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

<Project DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <UsingTask AssemblyFile="Path\To\GendarmeMsBuild.dll" TaskName="GendarmeMsBuild.Gendarme" />
    <Target Name="Test">
        <Gendarme
            OutputXmlFilename="$(MSBuildProjectDirectory)\bin\Debug\test-output.xml"
            Assemblies="Path\To\My\*.dll"
            />
    </Target>
</Project>

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"/>
</Target>

This should give you something like this:

Visual Studio screenshot

Options

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)

License

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

Thanks

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

Something went wrong with that request. Please try again.