Cake.OpenCppCoverage 1.0.0

dotnet add package Cake.OpenCppCoverage --version 1.0.0
                    
NuGet\Install-Package Cake.OpenCppCoverage -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cake.OpenCppCoverage" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cake.OpenCppCoverage" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Cake.OpenCppCoverage" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cake.OpenCppCoverage --version 1.0.0
                    
#r "nuget: Cake.OpenCppCoverage, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cake.OpenCppCoverage@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cake.OpenCppCoverage&version=1.0.0
                    

Cake.OpenCppCoverage

A Cake build extension for collecting code coverage using OpenCppCoverage.

Installation

Cake.OpenCppCoverage can be installed from the package manager console:

Install-Package Cake.OpenCppCoverage

It can also be used via a reference in your Cake build script using the #addin directive:

#addin nuget:?package=Cake.OpenCppCoverage

For this extension to work, OpenCppCoverage must be installed prior to execution. The releases for OpenCppCoverage can be found here: https://github.com/OpenCppCoverage/OpenCppCoverage/releases

Usage

To use this extension you create an OpenCppCoverage process runner, and use it to execute another process, which is typically the process running some tests. The OpenCppCoverage process runner executes OpenCppCoverage, passing it the path to your executable and any parameters you want to give to it.

Running the coverage process with default options will gather some coverage, but it will be incomplete without you providing more information. You will want to provide an output location for the coverage data, and the type of data you want it to output. You will also want to tell it what source files and modules to include in the data, for which wildcards are supported.

A typical usage may look like this:

var coverageOutputDirectory = DirectoryPath.FromString(coverageOutputPath);
var processRunner = GetOpenCppCoverageRunner(new OpenCppCoverageSettings
    {
        WorkingDirectory = coverageOutputDirectory,
        Sources = [GetRootedPath("src/*"))],
        Modules = ["*"],
        ExportTypes = [new Cake.OpenCppCoverage.Export.HtmlExportType(coverageOutputDirectory)]
    });

var result = GoogleTestRun(processRunner, GetRootedPath(executable), new GoogleTestSettings
{
    Output = new XmlTestOutput(GetRootedPath(outputFile))
});

Settings

The available settings for OpenCppCoverage can be found here: https://github.com/OpenCppCoverage/OpenCppCoverage/wiki/Command-line-reference

All settings can be set using the OpenCppCoverageSettings class, with the following associations:

Field Setting
Verbose --verbose
Quiet --quiet
ConfigFile --config_file
Modules --modules
ExcludedModules --excluded_modules
Sources --sources
ExcludedSources --excluded_sources
InputCoverage --input_coverage
ExportTypes --export_type
CoverChildren --cover_children
NoAggregateByFile --no_aggregate_by_file
UnifiedDiffs --unified_diff
ContinueAfterCppException --continue_after_cpp_exception
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 192 7/20/2025