I am working on a library and I want to be able to compile it for the traditional .NET Framework, but also for .NET core. I started out with a classic VS solution that worked fine for .NET Framework 4.5. Then I added a project.json
file that looked like this:
{
"version": "0.1.3-*",
"frameworks": {
"net45": {
"dependencies": {
}
},
"dnxcore50": {
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23811",
"System.Net.Http": "4.0.1-beta-23516",
"System.Security.Principal": "4.0.1-beta-23516",
"System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-23225",
"System.Security.Cryptography.X509Certificates": "4.0.0-beta-23516",
"System.Xml.XDocument": "4.0.11-beta-23516"
}
}
}
}
Now it compiles fine with .NET core, but VS 2015.1 complains that I am missing a runtimes section in my project.json
. I added the following piece of code to the file:
"runtimes": {
"win": {}
}
I tried to add it at the frameworks/net45 level, but this didn't help. It should be added at the root-level, but now it complains with the following error
<assembly> provides a compile-time reference assembly for <assembly> on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win.
There is plenty of documentation about how to use the project.json file with dnxcore, but documentation about using project.json with the traditional .NET framework is scarce. This is a pity, because it discourages developers to port their libraries to dnxcore, while maintaining compatibility with the traditional .NET framework which will be the most important framework for the next few years.