-
Notifications
You must be signed in to change notification settings - Fork 398
Failed to resolve assembly #560
Description
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=trueoption to thedotnet testcommand-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.dllC:\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.