microsoft / microsoft/codecoverage

Mono.Cecil fails to load when using Microsoft.Testing.Platform on net472

Open
#162 12 comments 1 reaction 1 assignee View on GitHub

@fhnaseer is already working on this.

Since Jul 31, 2025.

bug
Dominant language
C#
Stars
125
Forks
17
Avg merge
1h 17m
Merged PRs (30d)
2

Description

I'm attempting to adopt Microsoft.Testing.Platform and with it the new Microsoft.Testing.Extensions.CodeCoverage, however net472 tests all fail to run with the error

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Mono.Cecil, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Repro steps

Tests.cs
using Xunit;

public sealed class Tests
{
    [Fact]
    public void MyTest()
    {
        Assert.True(true);
    }
}
Tests.csproj
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net472;net8.0</TargetFrameworks>
    <TestProject>true</TestProject>
    <OutputType>Exe</OutputType>
    <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
    <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
    <TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="FluentAssertions" Version="7.2.0"/>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0"/>
    <PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.13.1" />
    <PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="1.6.2" />
    <PackageReference Include="Moq" Version="4.20.72"/>
    <PackageReference Include="Moq.Analyzers" Version="0.3.0"/>
    <PackageReference Include="xunit.v3" Version="2.0.0"/>
    <PackageReference Include="xunit.runner.visualstudio" Version="3.0.2"/>
  </ItemGroup>

</Project>

and then run dotnet test -- --coverage --coverage-output-format cobertura

Additional info

.NET SDK 9.0.201
Windows 11 24H2 OS Build 26100.3476

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.