100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
.NET

Target Frameworks and TFMs

Understanding Target Framework Monikers (TFMs) like net8.0 and netstandard2.0, and how to multi-target a .NET project.

FoundationsIntermediate9 min readJul 10, 2026
Analogies

Target Frameworks and TFMs

A Target Framework Moniker (TFM) is a short string like net8.0, net472, or netstandard2.0 that tells the compiler and NuGet which framework version and API surface a project targets, set via the <TargetFramework> element in the .csproj. The TFM determines which BCL (Base Class Library) APIs are available at compile time and which NuGet package versions are compatible, so choosing the wrong TFM can either block access to newer APIs or accidentally require a runtime your deployment environment doesn't have.

🏏

Cricket analogy: Like the format label on a match (Test, ODI, or T20) determining which rules and overs apply, a TFM like net8.0 determines exactly which API rules and language features are available to the compiler.

Common TFMs

net8.0 (and net6.0, net9.0, etc.) targets modern, unified .NET and is the default choice for new applications; net472 and similar net4xx monikers target the legacy Windows-only .NET Framework for maintaining older apps; netstandard2.0 is a special TFM that isn't a runtime itself but a specification — a class library targeting netstandard2.0 can be consumed by both .NET Framework 4.6.1+ and modern .NET, which makes it the standard choice when authoring a shared library that must work across both worlds.

🏏

Cricket analogy: Like a switch-hitting batter (netstandard2.0) who can play both a traditional Test match (net472) and a modern T20 franchise league (net8.0) with the same technique, a netstandard2.0 library works in both legacy and modern .NET.

Multi-Targeting

A single .csproj can target more than one framework simultaneously using <TargetFrameworks> (plural, with an 's') containing a semicolon-separated list, such as <TargetFrameworks>net8.0;net472</TargetFrameworks>. MSBuild then compiles the project once per TFM into separate output folders, and conditional compilation symbols like #if NET8_0 or #if NETFRAMEWORK let code branch to use different APIs per target — commonly needed by library authors who must support both legacy consumers and take advantage of newer APIs when available.

🏏

Cricket analogy: Like a player registered for both a domestic Ranji Trophy squad and an IPL franchise, playing under two separate rule sets in the same season, multi-targeting compiles a project under two separate TFMs simultaneously.

xml
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net8.0;net472;netstandard2.0</TargetFrameworks>
  </PropertyGroup>
</Project>
csharp
#if NET8_0_OR_GREATER
    var json = JsonSerializer.Serialize(order, JsonContext.Default.Order);
#else
    var json = JsonConvert.SerializeObject(order);
#endif

netstandard2.0 is not itself a runtime you can execute — it is a specification. You cannot run a class library that only targets netstandard2.0; it must be referenced by an executable project (like net8.0 console or web app) that provides the actual runtime.

  • A TFM (Target Framework Moniker) like net8.0 or net472 specifies which framework APIs a project can use.
  • netstandard2.0 is a specification, not a runtime, used for libraries that must work on both .NET Framework and modern .NET.
  • <TargetFramework> (singular) targets one framework; <TargetFrameworks> (plural) enables multi-targeting.
  • Multi-targeted projects compile once per TFM, producing separate output folders under bin/.
  • Preprocessor directives like #if NET8_0_OR_GREATER let code branch per target framework.
  • Choosing the right TFM affects both compile-time API availability and NuGet package compatibility.
  • New applications should generally target the latest LTS TFM (e.g., net8.0) unless legacy compatibility is required.

Practice what you learned

Was this page helpful?

Topics covered

#NET#NETCoreStudyNotes#MicrosoftTechnologies#TargetFrameworksAndTFMs#Target#Frameworks#TFMs#Common#StudyNotes#SkillVeris