FileLoadException for System.Runtime.InteropServices.RuntimeInformation on old-style .csproj test projects #697
Description
Hey, I’m currently migrating my projects to .NET Core 2.0 and as part of this, I’ve updated the Microsoft.Extensions.Logging.Console
dependency on some test projects to 2.0.
When I run tests that attempt to create a console logger, I get the following error:
Message: System.IO.FileLoadException : Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I assume this is related to the change introduced with #440 that got rid of the PlatformAbstractions
dependency. It also works fine for me in new-style .csproj
projects (including test projects) but it just fails with old-style test projects. For some odd reason, the same code within a console application runs fine, even on old-style projects.
My test is literally just the following:
[Fact]
public void TestConsoleLogger()
{
new LoggerFactory().AddConsole().CreateLogger("Test");
}
Is there anything I can do to avoid this problem other than upgrading to the newer .csproj
format? I’ve also tried referencing various different kinds of InteropServices
in the project but I couldn’t get it to work.
I’ve prepared a minimum test project that reproduces the problem over here.