1

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:

  • Close and reopen powershell
  • Run dotnet build and dotnet restore
  • Adding package references to the coverlet package in all of my .csproj files (though the one it was complaining about already had a reference for it, I assume from when it was installed)

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.

Novastorm
  • 1,439
  • 3
  • 26
  • 40

1 Answers1

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.

  • Many thanks, I was missing this parameter however the actual issue was a bit bizarre in my case (see my update) – Novastorm May 20 '19 at 15:37