coverlet.msbuild
1.0.1
Prefix Reserved
See the version list below for details.
dotnet add package coverlet.msbuild --version 1.0.1
NuGet\Install-Package coverlet.msbuild -Version 1.0.1
<PackageReference Include="coverlet.msbuild" Version="1.0.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="coverlet.msbuild" Version="1.0.1" />
<PackageReference Include="coverlet.msbuild"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add coverlet.msbuild --version 1.0.1
#r "nuget: coverlet.msbuild, 1.0.1"
#:package coverlet.msbuild@1.0.1
#addin nuget:?package=coverlet.msbuild&version=1.0.1
#tool nuget:?package=coverlet.msbuild&version=1.0.1
coverlet

Coverlet is a cross platform code coverage library for .NET Core, with support for line and method coverage.
Installation
Available on NuGet
Visual Studio:
PM> Install-Package coverlet.msbuild
.NET Core CLI:
dotnet add package coverlet.msbuild
How It Works
Coverlet integrates with the MSBuild system and that allows it to go through the following process:
Before Tests Run
- Locate the unit test assembly and selects all the referenced assemblies that have PDBs.
- Instruments the selected assemblies by inserting code to record sequence point hits to a temporary file.
After Tests Run
- Restore the original non-instrumented assembly files.
- Read the recorded hits information from the temporary file.
- Generate the coverage result from the hits information and write it to a file.
Note: The assembly you'd like to get coverage for must be different from the assembly that contains the tests
Usage
Coverlet doesn't require any additional setup other than including the NuGet package. It integrates with the dotnet test infrastructure built into the .NET Core CLI and when enabled will automatically generate coverage results after tests are run.
Code Coverage
Enabling code coverage is as simple as setting the CollectCoverage property to true
dotnet test /p:CollectCoverage=true
After the above command is run, a coverage.json file containing the results will be generated in the root directory of the test project. A summary of the results will also be displayed in the terminal.
Coverage Output
Coverlet can generate coverage results in multiple formats, which is specified using the CoverletOutputFormat property. Possible values include json (default), lcov and opencover. For example, the following command emits coverage results in the opencover format:
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
The output folder of the coverage result file can also be specified using the CoverletOutputDirectory property.
Excluding Classes/Methods From Coverage
By default, Coverlet instruments every method of every class but sometimes for any number of reasons you might want it to ignore a specific method or class altogether. This is easily achieved by creating and applying the ExcludeFromCoverage attribute to the method or the class. Coverlet uses just the type name so the ExcludeFromCoverage class can be created under any namespace you wish. Also, in line with standard C# convention, either ExcludeFromCoverage or ExcludeFromCoverageAttribute will work.
Roadmap
- Branch coverage
- Filter modules to be instrumented
- Support for more output formats (e.g. JaCoCo, Cobertura)
- Console runner (removes the need for requiring a NuGet package)
Issues & Contributions
If you find a bug or have a feature request, please report them at this repository's issues section. Contributions are highly welcome, however, except for very small changes, kindly file an issue and let's have a discussion before you open a pull request.
License
This project is licensed under the MIT license. See the LICENSE file for more info.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
This package has no dependencies.
NuGet packages (13)
Showing the top 5 NuGet packages that depend on coverlet.msbuild:
| Package | Downloads |
|---|---|
|
Corvus.Testing.SpecFlow.NUnit
A metapackage that encapsulates the required dependencies when using Corvus.Testing.SpecFlow and Endjin's standard practises. Also simplifies the dependency management process when using tools like Dependabot. |
|
|
Corvus.Testing.AzureFunctions.SpecFlow.NUnit
A metapackage that encapsulates the required dependencies when using Corvus.Testing.AzureFunctions.SpecFlow and Endjin's standard practises. Also simplifies the dependency management process when using tools like Dependabot. |
|
|
Dolittle.Common.Specs
Package Description |
|
|
Klinked.Cqrs
Simple to use CQRS library. |
|
|
Klinked.Cqrs.Logging
A logging decorator for the Klinked.Cqrs library that makes it easy to add logging to all commands, events, and queries. |
GitHub repositories (316)
Showing the top 20 popular GitHub repositories that depend on coverlet.msbuild:
| Repository | Stars |
|---|---|
|
Jackett/Jackett
API Support for your favorite torrent trackers
|
|
|
App-vNext/Polly
Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. From version 6.0.1, Polly targets .NET Standard 1.1 and 2.0+.
|
|
|
dotnet/orleans
Cloud Native application framework for .NET
|
|
|
MudBlazor/MudBlazor
Blazor Component Library based on Material Design principles with an emphasis on ease of use and extensibility
|
|
|
reactiveui/refit
The automatic type-safe REST library for .NET Core, Xamarin and .NET. Heavily inspired by Square's Retrofit library, Refit turns your REST API into a live interface.
|
|
|
dotnet/machinelearning
ML.NET is an open source and cross-platform machine learning framework for .NET.
|
|
|
reactiveui/ReactiveUI
An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.
|
|
|
domaindrivendev/Swashbuckle.AspNetCore
Swagger tools for documenting API's built on ASP.NET Core
|
|
|
dotnet/tye
Tye is a tool that makes developing, testing, and deploying microservices and distributed applications easier. Project Tye includes a local orchestrator to make developing microservices easier and the ability to deploy microservices to Kubernetes with minimal configuration.
|
|
|
mono/SkiaSharp
SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
|
|
|
Shane32/QRCoder
A pure C# Open Source QR Code implementation
|
|
|
dotnet/winforms
Windows Forms is a .NET UI framework for building Windows desktop applications.
|
|
|
microsoft/fluentui-blazor
Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications
|
|
|
tmenier/Flurl
Fluent URL builder and testable HTTP client for .NET
|
|
|
simplcommerce/SimplCommerce
A simple, cross platform, modulith ecommerce system built on .NET
|
|
|
sshnet/SSH.NET
SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
|
|
|
ivanpaulovich/clean-architecture-manga
:cyclone: Clean Architecture with .NET6, C#10 and React+Redux. Use cases as central organizing structure, completely testable, decoupled from frameworks
|
|
|
riok/mapperly
A .NET source generator for generating object mappings. No runtime reflection.
|
|
|
nuke-build/nuke
🏗 The AKEless Build System for C#/.NET
|
|
|
dotnet/samples
Sample code referenced by the .NET documentation
|
| Version | Downloads | Last Updated |
|---|---|---|
| 6.0.4 | 17,453,627 | 1/19/2025 |
| 6.0.3 | 1,481,713 | 12/30/2024 |
| 6.0.2 | 26,671,567 | 3/13/2024 |
| 6.0.1 | 2,154,781 | 2/20/2024 |
| 6.0.0 | 19,949,629 | 5/21/2023 |
| 3.2.0 | 22,446,757 | 10/29/2022 |
| 3.1.2 | 27,196,623 | 2/6/2022 |
| 3.1.1 | 645,713 | 1/30/2022 |
| 3.1.0 | 16,186,595 | 7/19/2021 |
| 3.0.3 | 13,005,585 | 2/21/2021 |
| 3.0.2 | 2,744,914 | 1/24/2021 |
| 3.0.1 | 671,258 | 1/16/2021 |
| 3.0.0 | 508,333 | 1/9/2021 |
| 2.9.0 | 21,285,510 | 5/30/2020 |
| 2.8.1 | 6,371,966 | 4/2/2020 |
| 2.8.0 | 8,043,015 | 1/3/2020 |
| 2.7.0 | 5,623,792 | 9/22/2019 |
| 2.6.3 | 2,890,956 | 7/1/2019 |
| 2.6.2 | 738,048 | 6/6/2019 |
| 2.6.1 | 1,440,274 | 5/8/2019 |
| 2.6.0 | 1,171,199 | 3/4/2019 |
| 2.5.1 | 2,791,237 | 1/17/2019 |
| 2.5.0 | 726,486 | 12/20/2018 |
| 2.4.0 | 1,028,426 | 11/28/2018 |
| 2.3.2 | 287,351 | 11/19/2018 |
| 2.3.1 | 741,789 | 10/16/2018 |
| 2.3.0 | 855,115 | 9/7/2018 |
| 2.2.1 | 493,782 | 8/11/2018 |
| 2.1.1 | 346,291 | 7/16/2018 |
| 2.1.0 | 162,076 | 7/6/2018 |
| 2.0.1 | 444,549 | 6/12/2018 |
| 2.0.0 | 113,794 | 5/17/2018 |
| 1.2.0 | 119,056 | 5/2/2018 |
| 1.1.1 | 58,451 | 4/17/2018 |
| 1.1.0 | 6,214 | 4/16/2018 |
| 1.0.2 | 52,359 | 4/2/2018 |
| 1.0.1 | 20,584 | 3/26/2018 |
| 1.0.0 | 283,743 | 3/21/2018 |