Skip to main content
Any Framework

Microsoft.CodeCoverage package brings infra for collecting code coverage from vstest.console.exe and "dotnet test".

Published
Nov 10, 2026
12d ago
Total Downloads
2.0B
2,035,705,796

Install

dotnet add package Microsoft.CodeCoverage --version 18.10.2

No framework information available.

README

Microsoft.CodeCoverage

Code coverage infrastructure for the Visual Studio Test Platform. This package enables collecting code coverage data from vstest.console.exe and dotnet test.

Usage

This package is typically referenced indirectly through Microsoft.NET.Test.Sdk. For standalone usage:

<PackageReference Include="Microsoft.CodeCoverage" Version="x.y.z" />

Collect code coverage during a test run:

dotnet test --collect "Code Coverage"

Published tests

dotnet publish places the collector, tools, and their private dependencies in the Microsoft.CodeCoverage subdirectory. Deploy the entire publish directory. VSTest's data collector host searches the test assembly's directory and its subdirectories, so it discovers the collector without a project or NuGet cache:

dotnet vstest publish/Tests.dll --collect:"Code Coverage"

For runners that require an explicit extension path, pass --TestAdapterPath:publish/Microsoft.CodeCoverage. Normal dotnet test runs continue to use the collector from the package directory.

When upgrading from a package that copied coverage files into the publish root, delete the old publish directory before publishing again. Old private dependencies in that directory cannot safely be distinguished from application files.

Links

Changes from Previous Version

No structural changes between v18.10.1 and v18.10.2.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

No target framework metadata is available. Confirm compatibility in a representative project before standardising on this package.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.