|
1 | 1 | --- |
2 | 2 | title: Target frameworks in SDK-style projects - .NET |
3 | 3 | description: Learn about target frameworks for .NET apps and libraries. |
4 | | -ms.date: 11/06/2025 |
| 4 | +ms.date: 04/15/2026 |
5 | 5 | ms.service: dotnet |
6 | 6 | ms.custom: updateeachrelease |
7 | 7 | ms.subservice: standard-library |
@@ -208,6 +208,35 @@ public class MyClass |
208 | 208 | } |
209 | 209 | ``` |
210 | 210 |
|
| 211 | +### TargetFramework values are aliases |
| 212 | + |
| 213 | +The `TargetFramework` property value (for example, `net10.0`) is a friendly name—an alias—that the .NET SDK translates into canonical moniker properties. Specifically, the SDK sets the following properties from the `TargetFramework` value: |
| 214 | + |
| 215 | +- `TargetFrameworkMoniker` (for example, `.NETCoreApp,Version=v10.0`) |
| 216 | +- `TargetFrameworkIdentifier` (for example, `.NETCoreApp`) |
| 217 | +- `TargetFrameworkVersion` (for example, `v10.0`) |
| 218 | +- `TargetPlatformMoniker`, `TargetPlatformIdentifier`, and `TargetPlatformVersion` (when targeting a specific platform) |
| 219 | + |
| 220 | +NuGet and the .NET SDK use these moniker properties—not the `TargetFramework` string—for package compatibility checks and build logic. This translation already happens for OS-specific TFMs. For example, `net10.0-windows` translates to `TargetFrameworkMoniker` = `.NETCoreApp,Version=v10.0` and `TargetPlatformMoniker` = `Windows,Version=7.0`. |
| 221 | + |
| 222 | +Because the alias is just a name, the `TargetFramework` value can be any alphanumeric string, as long as the corresponding moniker properties are set correctly. The following project file uses a custom alias named `banana` and explicitly sets the moniker properties so that the project builds and restores for .NET 10.0: |
| 223 | + |
| 224 | +```xml |
| 225 | +<Project Sdk="Microsoft.NET.Sdk"> |
| 226 | + <PropertyGroup> |
| 227 | + <TargetFramework>banana</TargetFramework> |
| 228 | + </PropertyGroup> |
| 229 | + |
| 230 | + <PropertyGroup Condition=" '$(TargetFramework)' == 'banana' "> |
| 231 | + <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier> |
| 232 | + <TargetFrameworkVersion>v10.0</TargetFrameworkVersion> |
| 233 | + <TargetFrameworkMoniker>.NETCoreApp,Version=v10.0</TargetFrameworkMoniker> |
| 234 | + </PropertyGroup> |
| 235 | +</Project> |
| 236 | +``` |
| 237 | + |
| 238 | +For more information about these properties, see the [TargetFramework](../core/project-sdk/msbuild-props.md#targetframework) MSBuild property reference. |
| 239 | + |
211 | 240 | ## Preprocessor symbols |
212 | 241 |
|
213 | 242 | The build system is aware of preprocessor symbols representing the target frameworks shown in the [Supported target framework versions](#supported-target-frameworks) table when you're using SDK-style projects. To convert a .NET Standard, .NET Core, or .NET 5+ TFM to a preprocessor symbol, replace dots and hyphens with an underscore, and change lowercase letters to uppercase (for example, the symbol for `netstandard2.0` is `NETSTANDARD2_0`). |
|
0 commit comments