Update
Per https://github.com/aspnet/Announcements/issues/98 the naming has changed a bit.
For RC1 applications and test projects should still target dnx4x and
dnxcore50 and don't need to change at all. Anything that has a
Program.Main or Startup.cs is considered an application.
Only class libraries should change to target net4x and dotnet5.x. For
class libraries the recommended conversion steps are:
In project.json:
Change dnx4x to net4x (e.g. dnx451 to net451)
Change dnxcore50 to dotnet5.4
And in your CS files:
Change #if DNX451 to #if NET451
Change #if DNXCORE50 to #if DOTNET5_4
If you have a project that targets multiple frameworks and want to add a general reference to a library, the library must support all those frameworks. If you specify that a certain framework itself references that library, then that library only needs to support the chosen framework.
Example if i want to reference library1 for all my frameworks:
"dependencies": {
"library1": "1.0.0"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
}
Then library1 must support dnx451 and dnxcore50
If I want to reference library1 but it only supports dnx451 then this is my only option:
"dependencies": {
},
"frameworks": {
"dnx451": {
"dependencies": {
"library1": "1.0.0"
}
},
"dnxcore50": { }
}
But that would mean the library1 code could not be used in dnx451.
To work around that you could use is using compile time conditionals:
#if DNX451
//Code here for dnx451
#elif DNXCORE50
//code here for dnxcore50
#endif
Or another work around is using another library for the other dependency
And just to clarify, the library can support more frameworks than your project. So library1 can support dnx451 and dnxcore50 while your project only supports dnx451 and it will be fine