Project A (.NET Standard 2.0) has a method that uses TestServer, so it has a reference to Microsoft.AspNetCore.TestHost
. It is built into a NuGet package.
Project B (.NET Standard 2.0) has a reference to the NuGet package from A. It is also built into a NuGet package.
Project C (.NET Core 2.2) is an XUnit test project, that has a reference to NuGet package B. It has a single test that calls the method from A.
All these projects compile successfully. But when the test from C is run, it fails with the following:
System.IO.FileNotFoundException : Could not load file or assembly'Microsoft.AspNetCore.TestHost, Version=2.2.0.0, Culture=neutral,PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
If I manually add a reference to Microsoft.AspNetCore.TestHost
to C, the test executes successfully. But from my understanding of .NET and how it handles transitive dependencies, this shouldn't be necessary.
Am I wrong, or is something broken here?