Could not load file or assembly due to assembly reference mismatch error when using Coverlet.Collector
We are encountering an assembly mismatch when utilizing Coverlet.Collector in our codebase (dotnetcore 3.1) when combined with FluentAssertions (in test projects) and Razorlight.Netcore3 (in a non test project that deals with sending out emails). More specifically, it's complaining about not being able to find a particular version of Microsoft.Extensions.Dependencymodel (which both Razorlight and FluentAssertions depend on).
What's truly strange about this is that Coverlet is only present in our Test projects, so we're not sure why that would affect our API project like this during runtime. Adding in microsoft.extensions.dependencymodel explicitly to the test project alleviates the issue (or just removing Coverlet entirely works as well).
Are there any insights as to why this would happen? At first, we thought maybe code coverage analyzers just do something wonky but we tried using AltCover and have not come across this problem.
Coverlet is using a dependency model for some corner case where it needs to load assemblies from shared framework, this is the version used https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.core/coverlet.core.csproj#L14 https://github.com/coverlet-coverage/coverlet/blob/master/Directory.Build.targets#L6
What's truly strange about this is that Coverlet is only present in our Test projects, so we're not sure why that would affect our API project like this during runtime
If the reference are project->tests you shouldn't have problem on "project deploy" because coverlet lib shouldn't be part of assets deployed. Are you able to create a repro?
Hey I'll try to get a repro into a repository sometime this week.
I think that this problem affects me as well. I am using the assembly Microsoft.Extensions.FileSystemGlobbing.dll and the wrong version ends up in the ArtifactStagingDirectory.
In TFS build, the working directory on the build agent has version 3.100.820.42004, that is the one I need.
After build, the ArtifactStagingDirectory contains version 2.0.1.18051.
I scanned all the nuget folders, and it is the nuget package coverlet.collector that has the earlier version.
\.nuget\packages\coverlet.collector\1.0.1\build\netstandard1.0 2.0.1.18051
\.nuget\packages\coverlet.collector\1.1.0\build\netstandard1.0 2.0.1.18051
\.nuget\packages\coverlet.collector\1.2.0\build\netstandard1.0 2.0.1.18051
\.nuget\packages\coverlet.collector\1.3.0\build\netstandard1.0 2.0.1.18051
\.nuget\packages\coverlet.msbuild\2.6.0\build\netstandard2.0 2.0.1.18051
\.nuget\packages\microsoft.aspnetcore.app.ref\3.0.1\ref\netcoreapp3.0 3.0.19.46305
\.nuget\packages\microsoft.aspnetcore.app.runtime.win-x64\3.0.1\runtimes\win-x64\lib\netcoreapp3.0 3.0.119.53103
\.nuget\packages\microsoft.aspnetcore.app.runtime.win-x64\3.1.0\runtimes\win-x64\lib\netcoreapp3.1 3.100.19.56504
\.nuget\packages\microsoft.extensions.filesystemglobbing\2.0.0\lib\netstandard2.0 2.0.0.17205
\.nuget\packages\microsoft.extensions.filesystemglobbing\2.1.0\lib\netstandard2.0 2.1.0.18136
\.nuget\packages\microsoft.extensions.filesystemglobbing\3.0.0\lib\netstandard2.0 3.0.19.46305
\.nuget\packages\microsoft.extensions.filesystemglobbing\3.0.1\lib\netstandard2.0 3.0.119.53103
\.nuget\packages\microsoft.extensions.filesystemglobbing\3.1.1\lib\netstandard2.0 3.100.119.61404
\.nuget\packages\microsoft.extensions.filesystemglobbing\3.1.3\lib\netstandard2.0 3.100.320.12802
\.nuget\packages\microsoft.extensions.filesystemglobbing\3.1.4\lib\netstandard2.0 3.100.420.21409
\.nuget\packages\microsoft.extensions.filesystemglobbing\3.1.6\lib\netstandard2.0 3.100.620.31605
\.nuget\packages\microsoft.extensions.filesystemglobbing\3.1.8\lib\netstandard2.0 3.100.820.42004
\.nuget\packages\nswag.msbuild\13.7.0\tools\NetCore21 2.1.1.18157
\.nuget\packages\nswag.msbuild\13.7.0\tools\NetCore22 2.2.0.18315
\.nuget\packages\nswag.msbuild\13.7.0\tools\Win 2.2.0.18315
So why does Microsoft.Extensions.FileSystemGlobbing.dll 2.0.1.18051 end up in ArtifactStagingDirectory?
Hi guys, can you confirm the private assets configuration for coverlet packages like
<PackageReference Include="coverlet.collector" Version="3.0.0-preview.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
I did a test and also after publish I cannot see nothing related to coverlet in publish folder, can you attach the publish command line? Some repro?
Closing for stale conversation, feel free to reopen if needed.