I have a simple Dll where I defined some class like this:
public class Parameters
{
public string Message { get; set; }
}
I added a NuGet package Newtonsoft.Json.
This DLL MUST be consumed by a netcoreapp1.1 and a net462.
I have tried to modify the csproj and added this
<TargetFramework>netstandard1.5</TargetFramework>
If I launch dotnet build the dll was build successfully but I cannot consume the DLL from the netcore app neither from net462
In particular if I add a xUnit test and reference a class inside the DLL it raise the error:
System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=4.1.0.0 [..]
Anybody can explain me how work net462, netcoreapp and netstandard1.5 target frameworks? And how build a dll cross framework?
UPDATE
For find the related assembly must be add the code below on xunit .csproj
<OutputType>Exe</OutputType>
You can find a table for
.Net Standardplatforms support here. You need to understand that.Net Standardis not a framework, it's a rules for libraries to implement for.Net Standardsupport.So, if you need your library to support both
.Net Coreand.Net Framework4.6, you need to target.Net Standard1.6.1 (!), not 1.5 or 1.6, and.Net Framework, according to this blog (note plural form of tag).Maybe it will work without the
net462, as it should support 1.6 version, I'll update later for this.Also I found
xUnitblog post about running tests against multiple targets, they used this:Note that they've targeted the
netcoreapp, not thenetstandard.