I created a multi-targeted framework project. I use something like this:
#if NET40
Console.WriteLine("Hello from .NET Core 4");
#endif
But I can't find a wildcard for .NET Core. I tried:
#if NETCOREAPP1.0
Console.WriteLine("Hello from .NET Core");
#endif
But it is not valid statement.
You need an underscore, _
, instead of a point:
NETCOREAPP1_0
or the more recent NETCOREAPP1_1
and NETCOREAPP2_0
The article Developing Libraries with Cross Platform Tools includes a list for the different preprocessor symbols.
.NET Framework 2.0: NET20
.NET Framework 3.5: NET35
.NET Framework 4.0: NET40
.NET Framework 4.5 --> NET45
.NET Framework 4.5.1 --> NET451
.NET Framework 4.5.2 --> NET452
.NET Framework 4.6 --> NET46
.NET Framework 4.6.1 --> NET461
.NET Framework 4.6.2 --> NET462
.NET Framework 4.7.0 --> NET47
.NET Framework 4.7.1 --> NET471
.NET Framework 4.7.2 --> NET472
.NET Standard Any --> NETSTANDARD
.NET Standard 1.0 --> NETSTANDARD1_0
.NET Standard 1.1 --> NETSTANDARD1_1
.NET Standard 1.2 --> NETSTANDARD1_2
.NET Standard 1.3 --> NETSTANDARD1_3
.NET Standard 1.4 --> NETSTANDARD1_4
.NET Standard 1.5 --> NETSTANDARD1_5
.NET Standard 1.6 --> NETSTANDARD1_6
.NET Standard 2.0 --> NETSTANDARD2_0
.NET Standard 2.1 --> NETSTANDARD2_1