Skip to content

System.MissingMethodException with collectors on .NET 5 #1047

@fredrikcarlbom

Description

@fredrikcarlbom

This is the first time trying coverlet but I cannot get it to work with either version 3.0.0 nor 1.3.0

This is my minimal test repository: https://github.com/fredrikcarlbom/coverlet/tree/main

This is the test project file from the repo - lib1.tests.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="coverlet.collector" Version="3.0.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

I build using build.sh:

#!/bin/bash

mkdir out
dotnet publish ./lib1.tests -c Release -o out
cd out
dotnet test lib1.tests.dll --collect:"XPlat Code Coverage"

And this is the complete output:

/mnt/c/Work/coverlet$ ./build.sh
mkdir: cannot create directory ‘out’: File exists
Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /mnt/c/Work/coverlet/lib1.tests/lib1.tests.csproj (in 351 ms).
  lib1.tests -> /mnt/c/Work/coverlet/lib1.tests/bin/Release/net5.0/lib1.tests.dll
  lib1.tests -> /mnt/c/Work/coverlet/out/
Microsoft (R) Test Execution Command Line Tool Version 16.8.3
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
'.ta collection : Unable to find a datacollector with friendly name 'XPlat Code Coverage
'ata collection : Could not find data collector 'XPlat Code Coverage
Testhost process exited with error: Unhandled exception. System.MissingMethodException: Method not found: 'Boolean Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers.CommandLineArgumentsHelper.TryGetIntArgFromDict(System.Collections.Generic.IDictionary`2<System.String,System.String>, System.String, Int32 ByRef)'.
   at Microsoft.VisualStudio.TestPlatform.TestHost.DefaultEngineInvoker.SetParentProcessExitCallback(IDictionary`2 argsDictionary)
   at Microsoft.VisualStudio.TestPlatform.TestHost.DefaultEngineInvoker.Invoke(IDictionary`2 argsDictionary)
   at Microsoft.VisualStudio.TestPlatform.TestHost.Program.Run(String[] args)
   at Microsoft.VisualStudio.TestPlatform.TestHost.Program.Main(String[] args)
. Please check the diagnostic logs for more information.

Test Run Aborted.

I have the same behavior when running in powershell and WSL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions