Skip to content

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

@MattKotsenas

Description

@MattKotsenas

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions