question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to resolve assembly

See original GitHub issue

I have a .Net Core 2.2 project using xUnit 2.4.0, the SonarScanner for MSBuild 4.7.1, and coverlet.msbuild 2.6.3 to measure code coverage of my unit tests. The project also uses Nest 6.4.0 (Elasticsearch high-level client for C#) and other related packages. The code and unit tests all work fine without the coverlet.msbuild package dependency.

When I add the coverlet.msbuild package dependency to my unit tests project, I get an error from coverlet.msbuild:

C:\Users\robert.h.patrick\.nuget\packages\coverlet.msbuild\2.6.3\build\coverlet.msbuild.targets(7,5): warning : [coverlet] Unable to instrument module: d:\src\cap\case-service\case-service.Tests\bin\Release\netcoreapp2.2\case-service.dll because : Failed to resolve assembly: 'Microsoft.Extensions.Logging.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' [d:\src\cap\case-service\case-service.Tests\case-service.Tests.csproj]
Test run for d:\src\cap\case-service\case-service.Tests\bin\Release\netcoreapp2.2\case-service.Tests.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 16.2.0-preview-20190606-02
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Test Run Successful.
Total tests: 47
     Passed: 47
 Total time: 1.7411 Seconds

Calculating coverage result...
  Generating report 'd:\src\cap\case-service\case-service.Tests\coverage.opencover.xml'

+--------+------+--------+--------+
| Module | Line | Branch | Method |
+--------+------+--------+--------+

+---------+------+--------+--------+
|         | Line | Branch | Method |
+---------+------+--------+--------+
| Total   | 100% | 100%   | 100%   |
+---------+------+--------+--------+
| Average | ∞%   | ∞%     | ∞%     |
+---------+------+--------+--------+

SonarScanner for MSBuild 4.7.1
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
...

I have spent days searching, reading, and trying various solutions to resolve this.

  • I tried adding a package dependency to the project (both the normal project and the unit test project).
  • I tried the adding the /p:CopyLocalLockFileAssemblies=true option to the dotnet test command-line.

The aforementioned DLL is present in multiple locations on my local machine:

  • C:\Users\robert.h.patrick\.nuget\packages\microsoft.extensions.logging.abstractions\2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll
  • C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.logging.abstractions\2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll).

The only reliable way to work around this problem is to drop the DLL in the unit tests project’s bin\Release\netcoreapp2.2 directory.

I have the same problem on my Jenkins build machine running on Amazon Linux 2.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:21

github_iconTop GitHub Comments

1reaction
rpatrick00commented, Sep 23, 2019

OK, I have a reproducer that should work outside of our environment. Since it still is loosely based on our business application, I have added you as a collaborator to the private GitHub project. Let me know if you need anything else.

1reaction
rpatrick00commented, Sep 22, 2019

I added the exclude filter and while it changed the output, the problem remains. I will continue trying to create a sample project…

D:\src\cap\case-service>dotnet test --no-build -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CopyLocalLockFileAssemblies=true /p:Exclude="[Microsoft.Extensions.Logging.Abstractions].*"
C:\Users\robert.h.patrick\.nuget\packages\coverlet.msbuild\2.6.3\build\coverlet.msbuild.targets(7,5): warning : [coverlet] Unable to instrument module: D:\src\cap\case-service\case-service.Tests\bin\Release\netcoreapp2.2\case-service.dll because : Failed to resolve assembly: 'Microsoft.Extensions.Logging.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' [D:\src\cap\case-service\case-service.Tests\case-service.Tests.csproj]
Test run for D:\src\cap\case-service\case-service.Tests\bin\Release\netcoreapp2.2\case-service.Tests.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 16.2.0-preview-20190606-02
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Test Run Successful.
Total tests: 47
     Passed: 47
 Total time: 1.9108 Seconds

Calculating coverage result...
  Generating report 'D:\src\cap\case-service\case-service.Tests\coverage.opencover.xml'

+--------------------------------------------------+--------+--------+--------+
| Module                                           | Line   | Branch | Method |
+--------------------------------------------------+--------+--------+--------+
| xunit.runner.reporters.netcoreapp10              | 1.1%   | 0.48%  | 5.08%  |
+--------------------------------------------------+--------+--------+--------+
| xunit.runner.utility.netcoreapp10                | 15.68% | 9.14%  | 21.03% |
+--------------------------------------------------+--------+--------+--------+
| xunit.runner.visualstudio.dotnetcore.testadapter | 45.76% | 35.92% | 47.76% |
+--------------------------------------------------+--------+--------+--------+

+---------+-------------------+-------------------+--------+
|         | Line              | Branch            | Method |
+---------+-------------------+-------------------+--------+
| Total   | 23.75%            | 17.9%             | 26.55% |
+---------+-------------------+-------------------+--------+
| Average | 7.91666666666667% | 5.96666666666667% | 8.85%  |
+---------+-------------------+-------------------+--------+
Read more comments on GitHub >

github_iconTop Results From Across the Web

xamarin component failed to resolve assembly
xamarin component failed to resolve assembly ... I am trying to build a xamarin component. I have a created a SomeLibrary.dll from a...
Read more >
"Failed to resolve assembly" errors #361 - xamarin/urho
If you get errors during build, doing a rebuild seems to clear it up.
Read more >
Fatal error in Unity CIL Linker (Failed to resolve assembly ...
My project won't compile to player builds. It seems to be related to the nunit.framework assembly. When I try to build a standalone...
Read more >
Failed to resolve assembly Error In Maui Class Library
Hello . I am trying to add DevExpress(Editor,Controls)(beta version and stable version ) with dotnet 6 and 7 NuGet to Maui Class Library...
Read more >
How to fix "Failed to resolve assembly"
I am working on edit existing string/icon resource in assembly. I use mono.cecil to parse, edit the resource and save.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found