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.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net472;netstandard2.0</TargetFrameworks>
</PropertyGroup>
</Project>
#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
1. What does TFM stand for in .NET?
2. What is netstandard2.0?
3. Which .csproj element enables multi-targeting multiple frameworks in one project?
4. What does the preprocessor directive #if NET8_0_OR_GREATER do?
5. Can you directly execute a class library that only targets netstandard2.0?
Was this page helpful?
You May Also Like
.NET Runtime vs SDK
The difference between the .NET Runtime (needed to run apps) and the .NET SDK (needed to build them), and when to install each.
Project and Solution Structure
How .csproj project files and .sln solution files organize .NET code, dependencies, and multi-project applications.
What Is .NET Core?
An overview of .NET Core as Microsoft's open-source, cross-platform runtime and how it evolved into the unified modern .NET.
Related Reading
Related Study Notes in Microsoft Technologies
Browse all study notesWindows 10 / UWP Development Study Notes
.NET · 30 topics
Microsoft TechnologiesWindows Batch Scripting Study Notes
Batch · 30 topics
Microsoft TechnologiesMFC (Microsoft Foundation Classes) Study Notes
C++ · 30 topics
Microsoft TechnologiesSilverlight Study Notes
.NET · 30 topics
Microsoft TechnologiesXAML Study Notes
.NET · 30 topics
Microsoft TechnologiesWPF (Windows Presentation Foundation) Study Notes
.NET · 30 topics