The "Coverlet.MSbuild.Tasks.CoverageResultTask" task was not given a value for the required param

Hello,

I m trying to get coverage count for MS test. while I am scan the unit test project using SonarScanner getting below error

Error:
.nuget\packages\coverlet.msbuild\2.7.0\build\coverlet.msbuild.targets(41,5): error MSB4044:
The “Coverlet.MSbuild.Tasks.CoverageResultTask” task was not given a value for the required parameter “InstrumenterState”.

So what all I have done:
A unit test project in VS 2019
Version : .Net core 3.1
Unit Test : Microsoft.NET.Test.Sdk 16.5.0
SonarQube Version: 9.7.1
SonarScanner Version: 2.7.0

Command:

  1. Install-Package coverlet.msbuild -Version 2.7.0

  2. dotnet test Test.UnitTest /p:CollectCoverage=true

Could you please help me with this ?

Hey there.

SonarQube only reads coverage reports – it’s not involved in producing them. It looks like your error is directly related to Coverlet, and you might want to look at this closed GitHub issue.

If you face issues importing test coverage after dotnet test Test.UnitTest /p:CollectCoverage=true runs successfully, this is the right place to ask!

(We do have some docs on .NET Test Coverage to show examples, and I am going to guess that you just need to install the coverlet collector NuGet package on your test project as mentioned)