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.

MSBuild fails if assembly being tested references Microsoft.AspNetCore.Cryptography.KeyDerivation

See original GitHub issue

MSBuild fails if the assembly being tested references Microsoft.AspNetCore.Cryptography.KeyDerivation. The error is:

/Users/jdoe/.nuget/packages/coverlet.msbuild/2.1.1/build/netstandard2.0/coverlet.msbuild.targets(15,5): error : Failed to resolve assembly: ‘Microsoft.AspNetCore.Cryptography.KeyDerivation, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60’ [/Users/jdoe/src/tmp/coverlet-fails-to-resolve-KeyDerivation/xunit-tests/xunit-tests.csproj]

Steps to Reproduce

Execute from CLI:

mkdir coverlet-fails-to-resolve-KeyDerivation
cd coverlet-fails-to-resolve-KeyDerivation

mkdir classlib
pushd classlib
dotnet new classlib
dotnet add package Microsoft.AspNetCore.Cryptography.KeyDerivation
popd

mkdir xunit-tests
pushd xunit-tests
dotnet new xunit
dotnet add reference ../classlib/classlib.csproj
dotnet add package coverlet.msbuild

Replace the contents of classlib/Class1.cs with:

using Microsoft.AspNetCore.Cryptography.KeyDerivation;
namespace classlib
{
    public class Class1
    {
        private const KeyDerivationPrf prf = KeyDerivationPrf.HMACSHA512;
    }
}

Execute from CLI (should still be in xunit-tests/ directory):

dotnet test /p:CollectCoverage=true

Expected Result

Build started, please wait...
Build completed.

Test run for /Users/jdoe/src/tmp/coverlet-fails-to-resolve-KeyDerivation/xunit-tests/bin/Debug/netcoreapp2.1/xunit-tests.dll(.NETCoreApp,Version=v2.1)
Microsoft (R) Test Execution Command Line Tool Version 15.7.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 2.6021 Seconds

Calculating coverage result...
  Generating report '/Users/jdoe/src/tmp/coverlet-fails-to-resolve-KeyDerivation/xunit-tests/coverage.json'

+----------+--------+--------+--------+
| Module   | Line   | Branch | Method |
+----------+--------+--------+--------+
| classlib | 0%     | 0%     | 0%     |
+----------+--------+--------+--------+

Actual Result

Build started, please wait...
Build completed.

/Users/jdoe/.nuget/packages/coverlet.msbuild/2.1.1/build/netstandard2.0/coverlet.msbuild.targets(15,5): error : Failed to resolve assembly: 'Microsoft.AspNetCore.Cryptography.KeyDerivation, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' [/Users/jdoe/src/tmp/coverlet-fails-to-resolve-KeyDerivation/xunit-tests/xunit-tests.csproj]
Test run for /Users/jdoe/src/tmp/coverlet-fails-to-resolve-KeyDerivation/xunit-tests/bin/Debug/netcoreapp2.1/xunit-tests.dll(.NETCoreApp,Version=v2.1)
Microsoft (R) Test Execution Command Line Tool Version 15.7.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 2.7978 Seconds

Calculating coverage result...
  Generating report '/Users/jdoe/src/tmp/coverlet-fails-to-resolve-KeyDerivation/xunit-tests/coverage.json'

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
tracker1commented, Sep 5, 2019

@MarcoRossignoli I’ll try to get it stripped out enough to be able to demo in a private repo and share it with you.

0reactions
MarcoRossignolicommented, Oct 14, 2019

Close because seem solved, I mean the above issue with reference not found. @tracker1 feel free to open a new issue with new 3.0 case(maybe try with prod release https://dotnet.microsoft.com/download/dotnet-core/3.0).

Read more comments on GitHub >

github_iconTop Results From Across the Web

MSBuild fails if assembly being tested references Microsoft. ...
MSBuild fails if the assembly being tested references Microsoft.AspNetCore.Cryptography.KeyDerivation. The error is: ...
Read more >
Why do this occurs "Could not load file or assembly.." in C# ...
To resolve this issue, double check your project's references and that there are no issues with the Microsoft.AspNetcore.Cryptography.
Read more >
Troubleshoot .NET Framework targeting errors
This topic describes MSBuild errors that might occur because of reference issues and how you can resolve those errors.
Read more >
MSB3277: Found conflicts between different versions of ' ...
This error occurs during a build when more than one version of the same dependent assembly is referenced in a build of the...
Read more >
The target “CoreCompile” does not exist in the project.
Friends,. I have an issue that my build server throws error saying 'The target “CoreCompile” does not exist in the project' but same...
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