You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
footer: "Are you interested in contributing to the .NET docs? For more information, see our [contributor guide](/contribute/dotnet/dotnet-contribute)."
footer: "Are you interested in contributing to the .NET docs? For more information, see our [contributor guide](/contribute/dotnet/dotnet-contribute)."
402
+
footer: "Are you interested in contributing to the .NET docs? For more information, see our [contributor guide](/contribute/dotnet/dotnet-contribute)."
@@ -53,52 +51,59 @@ A target framework is typically referenced by a TFM. The following table shows t
53
51
54
52
### .NET 5+ OS-specific TFMs
55
53
56
-
The `net5.0`, `net6.0`, `net7.0`, and `net8.0` TFMs include technologies that work across different platforms. Specifying an *OS-specific TFM* makes APIs that are specific to an operating system available to your app, for example, Windows Forms or iOS bindings. OS-specific TFMs also inherit every API available to their base TFM, for example, the `net6.0` TFM.
54
+
The `net5.0`, `net6.0`, `net7.0`, `net8.0`, and `net.0` TFMs include technologies that work across different platforms. Specifying an *OS-specific TFM* makes APIs that are specific to an operating system available to your app, for example, Windows Forms or iOS bindings. OS-specific TFMs also inherit every API available to their base TFM, for example, the `net9.0` TFM.
57
55
58
56
.NET 5 introduced the `net5.0-windows` OS-specific TFM, which includes Windows-specific bindings for WinForms, WPF, and UWP APIs. .NET 6 and later versions have additional OS-specific TFMs, for example, `net6.0-ios`.
59
57
60
58
The following table shows the compatibility of the .NET 5+ TFMs.
|`net5.0`| net1..4 (with NU1701 warning)<br />netcoreapp1..3.1 (warning when WinForms or WPF is referenced)<br />netstandard1..2.1 |
65
-
|`net5.0-windows`| netcoreapp1..3.1 (plus everything else inherited from `net5.0`) |
66
-
|`net6.0`| (Subsequent version of `net5.0`) |
67
-
|`net6.0-android`|`xamarin.android` (plus everything else inherited from `net6.0`) |
68
-
|`net6.0-ios`| Everything inherited from `net6.0`|
69
-
|`net6.0-maccatalyst`| Everything inherited from `net6.0`|
70
-
|`net6.0-macos`| Everything inherited from `net6.0`|
71
-
|`net6.0-tvos`| Everything inherited from `net6.0`|
72
-
|`net6.0-windows`| (Subsequent version of `net5.0-windows`) |
73
-
|`net7.0`| (Subsequent version of `net6.0`) |
74
-
|`net7.0-android`| (Subsequent version of `net6.0-android`) |
75
-
|`net7.0-ios`| (Subsequent version of `net6.0-ios`) |
76
-
|`net7.0-maccatalyst`| (Subsequent version of `net6.0-maccatalyst`) |
77
-
|`net7.0-macos`| (Subsequent version of `net6.0-macos`) |
78
-
|`net7.0-tizen`|`tizen40` (plus everything else inherited from `net7.0`) |
79
-
|`net7.0-tvos`| (Subsequent version of `net6.0-tvos`) |
80
-
|`net7.0-windows`| (Subsequent version of `net6.0-windows`) |
81
-
|`net8.0`| (Subsequent version of `net7.0`) |
82
-
|`net8.0-android`| (Subsequent version of `net7.0-android`) |
83
-
|`net8.0-browser`| Everything inherited from `net8.0`|
84
-
|`net8.0-ios`| (Subsequent version of `net7.0-ios`) |
85
-
|`net8.0-maccatalyst`| (Subsequent version of `net7.0-maccatalyst`) |
86
-
|`net8.0-macos`| (Subsequent version of `net7.0-macos`) |
87
-
|`net8.0-tizen`| (Subsequent version of `net7.0-tizen`) |
88
-
|`net8.0-tvos`| (Subsequent version of `net7.0-tvos`) |
89
-
|`net8.0-windows`| (Subsequent version of `net7.0-windows`) |
63
+
|`net5.0-windows`| netcoreapp1..3.1 (plus everything else inherited from `net5.0`) |
64
+
|`net6.0`| (Subsequent version of `net5.0`) |
65
+
|`net6.0-android`|`xamarin.android` (plus everything else inherited from `net6.0`) |
66
+
|`net6.0-ios`| Everything inherited from `net6.0`|
67
+
|`net6.0-maccatalyst`| Everything inherited from `net6.0`|
68
+
|`net6.0-macos`| Everything inherited from `net6.0`|
69
+
|`net6.0-tvos`| Everything inherited from `net6.0`|
70
+
|`net6.0-windows`| (Subsequent version of `net5.0-windows`) |
71
+
|`net7.0`| (Subsequent version of `net6.0`) |
72
+
|`net7.0-android`| (Subsequent version of `net6.0-android`) |
73
+
|`net7.0-ios`| (Subsequent version of `net6.0-ios`) |
74
+
|`net7.0-maccatalyst`| (Subsequent version of `net6.0-maccatalyst`) |
75
+
|`net7.0-macos`| (Subsequent version of `net6.0-macos`) |
76
+
|`net7.0-tizen`|`tizen40` (plus everything else inherited from `net7.0`) |
77
+
|`net7.0-tvos`| (Subsequent version of `net6.0-tvos`) |
78
+
|`net7.0-windows`| (Subsequent version of `net6.0-windows`) |
79
+
|`net8.0`| (Subsequent version of `net7.0`) |
80
+
|`net8.0-android`| (Subsequent version of `net7.0-android`) |
81
+
|`net8.0-browser`| Everything inherited from `net8.0`|
82
+
|`net8.0-ios`| (Subsequent version of `net7.0-ios`) |
83
+
|`net8.0-maccatalyst`| (Subsequent version of `net7.0-maccatalyst`) |
84
+
|`net8.0-macos`| (Subsequent version of `net7.0-macos`) |
85
+
|`net8.0-tizen`| (Subsequent version of `net7.0-tizen`) |
86
+
|`net8.0-tvos`| (Subsequent version of `net7.0-tvos`) |
87
+
|`net8.0-windows`| (Subsequent version of `net7.0-windows`) |
88
+
|`net9.0`| (Subsequent version of `net8.0`) |
89
+
|`net9.0-android`| (Subsequent version of `net8.0-android`) |
90
+
|`net9.0-browser`| (Subsequent version of `net8.0-browser`) |
91
+
|`net9.0-ios`| (Subsequent version of `net8.0-ios`) |
92
+
|`net9.0-maccatalyst`| (Subsequent version of `net8.0-maccatalyst`) |
93
+
|`net9.0-macos`| (Subsequent version of `net8.0-macos`) |
94
+
|`net9.0-tizen`| (Subsequent version of `net8.0-tizen`) |
95
+
|`net9.0-tvos`| (Subsequent version of `net8.0-tvos`) |
96
+
|`net9.0-windows`| (Subsequent version of `net8.0-windows`) |
90
97
91
98
To make your app portable across different platforms but still have access to OS-specific APIs, you can target multiple OS-specific TFMs and add platform guards around OS-specific API calls using `#if` preprocessor directives. For a list of the available symbols, see [Preprocessor symbols](#preprocessor-symbols).
92
99
93
100
#### Suggested targets
94
101
95
102
Use these guidelines to determine which TFM to use in your app:
96
103
97
-
- Apps that are portable to multiple platforms should target a base TFM, for example, `net8.0`. This includes most libraries but also ASP.NET Core and Entity Framework.
98
-
99
-
- Platform-specific libraries should target platform-specific flavors. For example, WinForms and WPF projects should target `net8.0-windows`.
100
-
101
-
- Cross-platform application models (Xamarin Forms, ASP.NET Core) and bridge packs (Xamarin Essentials) should at least target the base TFM, for example, `net8.0`, but might also target additional platform-specific flavors to light-up more APIs or features.
104
+
- Apps that are portable to multiple platforms should target a base TFM, for example, `net9.0`. This includes most libraries but also ASP.NET Core and Entity Framework.
105
+
- Platform-specific libraries should target platform-specific flavors. For example, WinForms and WPF projects should target `net9.0-windows`.
106
+
- Cross-platform application models (Xamarin Forms, ASP.NET Core) and bridge packs (Xamarin Essentials) should at least target the base TFM, for example, `net9.0`, but might also target additional platform-specific flavors to light-up more APIs or features.
102
107
103
108
#### OS version in TFMs
104
109
@@ -110,9 +115,8 @@ The following table shows the default target platform values (TPV) for each .NET
110
115
111
116
| .NET version | Android | iOS | Mac Catalyst | macOS | tvOS | Tizen | Windows |
> On Apple platforms (iOS, macOS, tvOS, and Mac Catalyst) in .NET 8 and earlier,
@@ -155,14 +159,14 @@ Here is an example excerpt of a project file that uses the `TargetFramework` and
155
159
156
160
## How to specify a target framework
157
161
158
-
Target frameworks are specified in a project file. When a single target framework is specified, use the [TargetFramework element](../core/project-sdk/msbuild-props.md#targetframework). The following console app project file demonstrates how to target .NET 8:
162
+
Target frameworks are specified in a project file. When a single target framework is specified, use the [TargetFramework element](../core/project-sdk/msbuild-props.md#targetframework). The following console app project file demonstrates how to target .NET 9:
Copy file name to clipboardExpand all lines: docs/standard/library-guidance/cross-platform-targeting.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Cross-platform targeting for .NET libraries
3
3
description: Best practice recommendations for creating cross-platform .NET libraries.
4
-
ms.date: 11/14/2023
4
+
ms.date: 11/11/2024
5
5
---
6
6
7
7
# Cross-platform targeting
@@ -33,7 +33,7 @@ If your project targets .NET or .NET Standard and compiles successfully, it does
33
33
34
34
✔️ DO include a `net6.0` target or later if you require new APIs introduced in a modern .NET.
35
35
36
-
> .NET 6 and later apps can use a `netstandard2.0` target, so `net6.0` isn't required. You should explicitly target `net6.0`, `net7.0`, or `net8.0` when you want to use newer .NET APIs.
36
+
> .NET 6 and later apps can use a `netstandard2.0` target, so `net6.0` isn't required. You should explicitly target `net6.0`, `net7.0`, `net8.0`, or `net9.0` when you want to use newer .NET APIs.
0 commit comments