Skip to content

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

@nwoolls

Description

@nwoolls

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 |
+--------+--------+--------+--------+

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions