"Coverlet.MSbuild.Tasks.CoverageResultTask" task was not given a value for the required parameter "InstrumenterState"
See original GitHub issueHello,
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)
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:
- Created 4 years ago
- Reactions:5
- Comments:13
Top GitHub Comments
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.
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<