question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Coverlet.MSbuild.Tasks.CoverageResultTask" task was not given a value for the required parameter "InstrumenterState"

See original GitHub issue

Hello,

I have setup a post build event in my shared test library, this library has not tests but is referenced by all my test projects, I did this because I want to automatically generate the reports every-time the projects are built.

  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="cd $(SolutionDir)&#xD;&#xA;dotnet test" />
  </Target>

however I am getting the following error when I try to build the solution and the build hangs:

C:\...\packages\coverlet.msbuild\2.6.2\build\coverlet.msbuild.targets(41,5): error MSB4044: The "Coverlet.MSbuild.Tasks.CoverageResultTask" task was not given a value for the required parameter "InstrumenterState".

Directory.Build.Props `<Project> <Import Project="..\Directory.Build.props" Condition="Exists('..\Directory.Build.props')" />

<PropertyGroup>
    <IsTestProject>false</IsTestProject>
    <IsTestProject Condition="$(MSBuildProjectName.EndsWith('Tests')) OR $(MSBuildProjectName.EndsWith('Test'))">true</IsTestProject>
    <CollectCoverage Condition="!$(IsTestProject)">false</CollectCoverage>
    <CollectCoverage Condition="$(IsTestProject) AND $(CollectCoverage) == ''">true</CollectCoverage>
</PropertyGroup>

<PropertyGroup Label="CollectCodeCoverageResults" Condition="$(IsTestProject) AND $(CollectCoverage)">
    <CoverletOutputFormat>opencover</CoverletOutputFormat>
<_SlnDir>..\..\</_SlnDir>
    <_BaseDir>..\..\coverage-results\</_BaseDir>
    <CoverletBaseDir>$(_BaseDir)Coverage\</CoverletBaseDir>
    <CoverletResultsDir>$(_BaseDir)Results\</CoverletResultsDir>
    <CoverletBaseDir Condition="$([MSBuild]::IsOSUnixLike())">$(CoverletBaseDir.Replace('\', '/'))</CoverletBaseDir>
<SolutionDir Condition="$([MSBuild]::IsOSUnixLike())">$(_SlnDir.Replace('\', '/'))</SolutionDir>
    <CoverletResultsDir Condition="$([MSBuild]::IsOSUnixLike())">$(CoverletResultsDir.Replace('\', '/'))</CoverletResultsDir>
    <CoverletOutput>$(CoverletBaseDir)$(MSBuildProjectName).xml</CoverletOutput>
    <Exclude>[xunit*]*,[*Tests]*,[*Test]*</Exclude>
</PropertyGroup>

</Project>`

Directory.Build.Targets `<Project> <Import Project="..\Directory.Build.targets" Condition="Exists('..\Directory.Build.targets')" />

<ItemGroup>
    <DotNetCliToolReference Include="dotnet-reportgenerator-cli" Version="4.1.10" />
    <PackageReference Include="coverlet.msbuild" Version="2.6.2">
        <PrivateAssets>all</PrivateAssets>
        <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
    <PackageReference Include="xunit.runner.reporters" Version="2.4.1" />
    <PackageReference Include="xunit.runner.utility" Version="2.4.1" />
    <PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.13" />
</ItemGroup>

<Target Name="CovertReportResults" AfterTargets="GenerateCoverageResult" Condition="$(CollectCoverage)">
    <!-- Merges the reports into one for both cobertura and sonarqube formats -->
    <Exec Command="dotnet reportgenerator -reports:$(CoverletBaseDir)*.xml -targetdir:$(CoverletResultsDir) -reporttypes:Cobertura;SonarQube -verbosity:Verbose" WorkingDirectory="$(ProjectDir)" />
    <!-- Gives the summary in an Azure Pipelines look & feel -->
    <Exec Command="dotnet reportgenerator -reports:$(CoverletResultsDir)Cobertura.xml -targetdir:$(CoverletResultsDir) -reporttypes:HtmlInline_AzurePipelines;Cobertura -verbosity:Verbose" WorkingDirectory="$(ProjectDir)" />

<Exec Command="dotnet reportgenerator -reports:$(CoverletResultsDir)Cobertura.xml -targetdir:$(SolutionDir) -reporttypes:TextSummary -verbosity:Verbose" WorkingDirectory="$(ProjectDir)" />
</Target>

</Project>`

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:13

github_iconTop GitHub Comments

5reactions
fkucukcommented, Jul 29, 2019

for the record, I’ve faced the same error, and I’ve realized that I’ve had added coverlet nuget to business projects. When I removed it, it’s been fixed.

2reactions
maxoizscommented, Aug 19, 2019

in my case after getting that error, I’ve installed MS.Net.Test.Sdk which cleared the error so in my test project package I do have coverlet.msbuild version=“2.6.3” Microsoft.NET.Test.Sdk version=“16.2.0” Microsoft.CodeCoverage version=“16.2.0” — which a dependency of Sdk

<

Read more comments on GitHub >

github_iconTop Results From Across the Web

The "Coverlet.MSbuild.Tasks.CoverageResultTask ...
The “Coverlet.MSbuild.Tasks.CoverageResultTask” task was not given a value for the required parameter “InstrumenterState”.
Read more >
Error when running unit test from console using Visual ...
MSbuild.Tasks.CoverageResultTask" task was not given a value for the required parameter "InstrumenterState". msbuild .net ...
Read more >
使用VisualStudio17.1从控制台运行单元测试时出错
... MSB4044: The "Coverlet.MSbuild.Tasks.CoverageResultTask" task was not given a value for the required parameter "InstrumenterState".
Read more >
coverlet
coverlet. Cross platform code coverage library for .NET Core. Become a Bounty Hunter You're a Bounty Hunter. View Bounties; Unsubscribe from coverlet ......
Read more >
Birim testi için kod kapsamını kullanma - .NET
Bu makale, test çerçevesi olarak C# ve xUnit'e odaklansa da, hem MSTest hem de NUnit de çalışır. Coverlet, GitHub'da C# için platformlar arası ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found