0

I'm certain these tests were running fine before I upgraded .NET Core, but I can't figure out how they are broken or why.

I have three libraries that I have developed. We'll call them A, B, and C. B depends on A directly, and C depends on B and A directly. They are all multi-targeted as .NET Standard 1.1+ and .NET Framework 4.5 libraries.

Libraries A and B work perfectly fine. The unit tests for library B rely on A functioning correctly, as a transitive dependency of library B. The build still works and the tests (xUnit) run fine.

In library C, I consume A and B directly. Although C and its unit tests build just fine, they don't run correctly. The unit test project for C is laid out exactly the same as library B's.

<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworks>netcoreapp1.1;net452</TargetFrameworks> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> <PackageReference Include="xunit" Version="2.2.0" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\C\C.csproj" /> </ItemGroup> <ItemGroup> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> </ItemGroup> 

When running the unit tests (in Visual Studio, dotnet test, or Cake), all tests pass under the full framework. When the .NET Core unit tests run, those that rely on a helper method from B (which in turn uses A) throw an exception:

System.IO.FileLoadException: Could not load file or assembly 'A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621) 

I've checked the obvious problems: the library exists on our internal NuGet feed, the version numbers match between B and C (there's only one version, so no assembly binding redirects either), and A and B are definitely .NET Standard libraries, so they will work under .NET Core 1.1. I'm at a total loss because the .NET Framework version of the tests runs just fine, and I'm quite certain I would have noticed my tests failing before now. Does anyone have any suggestions?

1 Answer 1

4

There is a bug in .NET Core 1.1 regarding assemblies that are referenced by file: https://github.com/dotnet/coreclr/issues/10037#issuecomment-285394031

Could that issue apply here?

Sign up to request clarification or add additional context in comments.

1 Comment

That indeed seems to be it. I upgraded the tests to netcoreapp2.0 and they work successfully. Thank you!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.