.NET Platform Conditional Tags in .csproj

In addition to symbols you can use in code, one can also use TFMs in .csproj files for instance to decide which references to use depending on target framework, like so:

   <ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.4'">
      <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
   </ItemGroup>

Here is the list of all the TFMs known today:

Target FrameworkTFM
.NET 5 (and .NET Core)netcoreapp1.0netcoreapp1.1netcoreapp2.0netcoreapp2.1netcoreapp2.2netcoreapp3.0netcoreapp3.1net5.0*
.NET Standardnetstandard1.0netstandard1.1netstandard1.2netstandard1.3netstandard1.4netstandard1.5netstandard1.6netstandard2.0netstandard2.1
.NET Frameworknet11net20net35net40net403net45net451net452net46net461net462net47net471net472net48
Windows Storenetcore [netcore45]netcore45 [win] [win8]netcore451 [win81]
.NET Micro Frameworknetmf
Silverlightsl4sl5
Windows Phonewp [wp7]wp7wp75wp8wp81wpa81
Universal Windows Platformuap [uap10.0]uap10.0 [win10] [netcore50]


To contact me, send an email anytime or leave a comment below.