With the new MsBuild version it's really easy to target multiple frameworks and framework versions in .csproj project:
<TargetFrameworks>net40;net45;net461;netcoreapp1.1</TargetFrameworks>
Now, how do I get a constant defined for each of them so that I can have certain code only be part of e.g. netcoreapp1.1
pass and not full framework compilation?
I'd like to be able to add a preprocessor directive like this one:
#if NET_CORE
// some code
#endif
And the same for full .NET Framework and possibly .NET Standard.
The other questions I found don't take new <TargetFrameworks>
way of defining the framework into accounts. Stuff like this doesn't work:
<DefineConstants Condition=" '$(TargetFramework)' == '.NETCoreApp' ">NET_CORE</DefineConstants>