Novastorm
Novastorm

Reputation: 1458

Object Reference not set to an instance with Coverlet dotnet core

I've recently installed coverlet 2.6.0 via the dotnet core CLI (command: dotnet add package coverlet.msbuild) by following this guide: https://dev.to/deinsoftware/net-core-unit-test-and-code-coverage-with-visual-studio-code-37bp however I've run into issues running the first command:

dotnet test /p:CollectCoverage=true

When I run this in the root of my dotnet core application I get the following error:

C:\Users\me\.nuget\packages\coverlet.msbuild\2.6.0\build\netstandard2.0\coverlet.msbuild.targets(35,5): error : Object reference not set to an instance of an Object. [C:\Users\me\..\myproj.csproj] C:\Users\me\.nuget\packages\coverlet.msbuild\2.6.0\build\netstandard2.0\coverlet.msbuild.targets(35,5): error : at Coverlet.MSbuild.Tasks.CoverageResultTask.Execute() in /Users/toni/Workspace/coverlet/src/coverlet.msbuild.tasks/CoverageResultTask.cs:line 67 [C:\Users\me..\myproj.csproj]

I've tried the following to no avail:

I'm really stumped how to get it working, all other guides appear to be able to without issue. My project is running .NET Core 2.2.

EDIT [20/05/2019]

I managed to get this working by installing the references to Coverlet using Visual Studio as opposed to purely using the CLI. I'm unsure if this is specific to my (Windows) computer but thought I'd mention it here in case anyone else comes across the same thing.

Upvotes: 1

Views: 1097

Answers (1)

The problem you have described could be caused by the 2.6.0 version.

Taken from this GitHub issue (tomap's response):

Append /p:Exclude="[xunit*]*" to the command you are running.

Upvotes: 1

Related Questions