The following example will call JetBrains InspectCode and output the number of warnings.

To call JetBrains InspectCode from a Cake script you need to add the JetBrains.ReSharper.CommandLineTools:

#tool "nuget:?package=JetBrains.ReSharper.CommandLineTools"

To read issues from InspectCode log files you need to import the core addin and the InspectCode support:

#addin "Cake.Issues"
#addin "Cake.Issues.InspectCode"

Please note that you always should pin addins and tools to a specific version to make sure your builds are deterministic and won't break due to updates to one of the packages.

See pinning addin versions for details.

We need some global variables:

var logPath = @"c:\build\inspectcode.xml";
var repoRootPath = @"c:\repo";

The following task will run JetBrains InspectCode and write a log file:

Task("Analyze-Project").Does(() =>
    // Run InspectCode.
    var settings = new InspectCodeSettings() {
        OutputFile = logPath

    InspectCode(repoRootPath.CombineWithFilePath("MySolution.sln"), settings);

Finally you can define a task where you call the core addin with the desired issue provider.

    .Does(() =>
        // Read Issues.
        var issues =

        Information("{0} issues are found.", issues.Count());