Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preprocessor Directives in .Net Core for multiple frameworks

I am trying to port several libraries from .NET Framework 4.0 to .NET Core, and saw that one of the useful things you can do is add things like the following that will conditionally compile portions of your code:

#if NETCOREAPP1_0
    do something
#elif NET40
    do something else
#endif

My question is what to put in place of the NET40 in the code above. I have only been able to get NETCOREAPP1_0 and NETSTANDARD1_6 to be recognized. Every other thing I've put in for the NET40 hasn't worked, including net40, NET40, NET4_0, and a few others. Is there a list somewhere that would give guidance on how to reference it? Or is there additional steps I need to take in another portion of the project to get it to recognize net40?

like image 419
PirateJubber Avatar asked Nov 09 '22 12:11

PirateJubber


1 Answers

Try using DNX40. Something along the lines of

#if NETCOREAPP1_0
do something
#elif DNX40
do something else
#endif

This is taken from asp.net though, from this video: https://channel9.msdn.com/Events/dotnetConf/2015/ASPNET-5-Deep-Dive around the 36 minute mark. Usually the .net stuff works for the full framework.

like image 177
Kyle Avatar answered Dec 12 '22 21:12

Kyle