Blog
Creating a .NET Core Console Application supporting multiple frameworks
Yesterday, I had to use a non-ASP.NET Core portable class library in a .NET Core Console Application. With .NET Core, this operation is easy. Indeed, you just have to add a reference to the correct framework in your application's project.json file, and everything will work fine.
This is my project.json before any modification (note that this is the default project.json file):

To know which framework you have to target, look in the properties of the portable class library (you can see here that I have to target the .NET Framework 4.5):

To target the .NET Framework 4.5 in your .NET Core Console Application, you just have to adjust the frameworks you target in the "frameworks" section of your project.json file. After the modification, it will look like this:

You can see here that I'm still targeting the .NET Core 1.0.1 framework, but I also reference the .NET 4.5 portable framework, which allows me to reference the two .NET 4.5 portable class libraries I needed to use, libvideo and ClassLibrary2.
Here I needed to include the .NET 4.5 portable framework, but I could also add any other .NET framework, like .NET Framework 4.5.2 for example.
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
},
"frameworks": {
"net452": {
},
"netcoreapp1.0": {
"imports": "dnxcore50",
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
}
},
"dotnet": {
"imports": "portable-net45",
"dependencies": {
"ClassLibrary2": {
"target": "project"
},
"libvideo": {
"target": "project"
}
}
}
}
}
With this project.json, you can see that my console application has the 3 frameworks:
