Coverlet: ` Failed to resolve assembly` when running dotnet test with coverage

Created on 9 Apr 2018  路  11Comments  路  Source: coverlet-coverage/coverlet

When I run command
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
all test are passing and code coverage is correctly generated which is good. However returned exit code from command is 1 due to this error:

coverlet.msbuild\1.0.2\build\netstandard2.0\coverlet.msbuild.targets(13,5): error : Failed to resolve assembly: 'Common, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' [C:\Source\Repos\MyApp\src\Test\Test.csproj]

Where Common is one of the referenced projects.
When I just run dotnet test everything is working and exit code is 0.

duplicate

Most helpful comment

Just for reference, I had the same issue with some 3rd party packages, even with version 1.1.1.
Including
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
in the project file of my test project fixed it for me.

All 11 comments

I believe this is the same as #21 which has been fixed in #23. A new NuGet package will go out next Monday with this fix

New NuGet released https://www.nuget.org/packages/coverlet.msbuild/1.1.0. Feel free to reopen if you still run into the issue

Works like a charm. Thank you!

Just for reference, I had the same issue with some 3rd party packages, even with version 1.1.1.
Including
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
in the project file of my test project fixed it for me.

Confirmed, I've got Failed to resolve assembly: 'Microsoft.Extensions.Logging.Abstractions error and <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> solved my issue, too.

PS: An even better way than modifying your *.csprof file is to run dotnet test like
dotnet test /p:CollectCoverage=true /p:CopyLocalLockFileAssemblies=true

Thanks !

This also solved an issue for me when running tests on libraries relying on StackExchange.Redis.StrongName
with errors like coverlet.msbuild.targets(7,5): error : Failed to resolve assembly: 'StackExchange.Redis.StrongName, Version=1.2.6.0

Confirmed, I've got Failed to resolve assembly: 'Microsoft.Extensions.Logging.Abstractions error and running dotnet test like
dotnet test /p:CollectCoverage=true /p:CopyLocalLockFileAssemblies=true solved my issue, too.

Perhaps this can be added to the README.md, @tonerdo?

Had this happening with 2.3.2. /p:CopyLocalLockFileAssemblies=true fixed it.

Is using /p:CopyLocalLockFileAssemblies=true or <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> the prescribed way to fix this error? Any plans/thoughts on a fix that wouldn't require using this parameter?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hlubovac picture hlubovac  路  5Comments

ghost picture ghost  路  5Comments

mateusdemboski picture mateusdemboski  路  6Comments

felixfbecker picture felixfbecker  路  6Comments

obtuse-whoosh picture obtuse-whoosh  路  6Comments