The following example will call DocFx to generate the documentation and outputs the number of warnings.

To call DocFx from a Cake script you can use the Cake.DocFx addin.

#addin "Cake.DocFx"

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

#addin "Cake.Issues"
#addin "Cake.Issues.DocFx"

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

See pinning addin versions for details.

We need some global variables:

var logPath = @"c:\build\docfx.log";
var repoRootPath = @"c:\repo";
var docRootPath = @"docs";

The following task will build the DocFx project and write a log file:

Task("Build-Documentation").Does(() =>
    // Run DocFx.
    DocFxBuild(new DocFxBuildSettings()
        LogPath = logPath

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

    .Does(() =>
        // Read Issues.
        var issues =
                DocFxIssuesFromFilePath(logPath, docRootPath),

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