What would you use in a #if
when targeting .Net 5.0?
i.e. for the other frameworks
.NET Framework
NETFRAMEWORK, NET20, NET35, NET40, NET45, NET451, NET452, NET46, NET461, NET462, NET47, NET471, NET472, NET48
.NET Standard
NETSTANDARD, NETSTANDARD1_0, NETSTANDARD1_1, NETSTANDARD1_2, NETSTANDARD1_3, NETSTANDARD1_4, NETSTANDARD1_5, NETSTANDARD1_6, NETSTANDARD2_0, NETSTANDARD2_1
.NET Core
NETCOREAPP, NETCOREAPP1_0, NETCOREAPP1_1, NETCOREAPP2_0, NETCOREAPP2_1, NETCOREAPP2_2, NETCOREAPP3_0, NETCOREAPP3_1
If you set the build output to "detailed" and try this today, you should see something like (among the rest of the output - near a csc.exe
mention):
/define:TRACE;DEBUG;NETCOREAPP;NETCOREAPP5_0
so: NETCOREAPP5_0
is what you're looking for - but: whether this stays the same at launch may change. You can repeat the same process at a later date to find out.
The preprocessor definitions changed in dotnet/sdk#12124 to fit this design before .NET 5 was released. The released version defines:
NETCOREAPP
NET5_0
This is now also documented in #if (C# reference). It does not define NETCOREAPP5_0
anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With