Reputation: 13390
Usually we see the following targets in project.json
:
"frameworks": {
"net45": {},
"dnx451": {},
"dnxcore50": { }
}
dnxcore50
will be the only portable version of the project code and dnx451
actually targets .Net 4.5.1 mscorlib etc...
Now, if I add another target called dnx50
, this will create a valid output and works just fine.
The difference between dnx451 and dnx50 is, that it references different .Net assembly dlls
For example mscorlib.dll
:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\mscorlib.dll
C:\Windows\Microsoft.NET\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
which essentially is the .net 4.6 version.Question now is:
Does it make sense to create that dnx50
target for your custom library for example? Basically to target .net 4.6 and you need certain functionality the dnxcore50
portable doesn't have?
Or is the dnx451
target actually enough, and if I don't need a specific feature from the more recent .net versions (4.5.2, 4.6), this target would use .net 4.6 anyways if it is installed on the system and I'm just targeting the lowest version necessary for my project?
Does that mean that having both, a dnx451 and dnx50 target, would actually create the same output, right?
Upvotes: 12
Views: 2471
Reputation: 38467
See this question for full details. Here is a list of all the different types you can use:
dnxcore50
- DNX SDK running on CoreCLR/CoreFxdnx451
- DNX SDK running on .Net 4.5.1 (Desktop CLR / Full BCL and FCL)net46
- .Net Framework SDK running on .Net 4.6 (Desktop CLR / Full BCL and FCL).uap10.0
- UWP SDK running on .Net Native/CoreFxdotnet
- any pure IL code which declares its dependencies (instead of a PCL contract). Framework dependencies are available for .Net 4.6, DNX or UWP.For .NET 4.5 you need to use dnx45
for ASP.NET projects and net45
for other projects to target .NET 4.5. Which one you target depends on what you want to do, you can even target more than one at a time.
Currently the .NET Core (DNX) has very limited functionality. If this does not give you enough, then target the full .NET runtime dnx46
for ASP.NET 5 using .NET 4.6 and net46
for other projects using .NET 4.6.
Upvotes: 5
Reputation: 17671
The names you give build targets are your own and you can use any name you choose so this will work fine.
The build targets also generate global, upper case #define statements you can use for #if DNXCORE50 logic block bracketing in your code.
However, while it will work, I think it's a good idea to stick to the official targets that Microsoft provides lest it create project linking issues. You can create new targets but then any consuming application also has to actually be able to use those targets. So in your own projects that will work fine, but if it's a generic project of some sort you need to make sure you document custom build targets.
Upvotes: 0