Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/core/deploying/native-aot/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ The preceding configuration assigns a default of `true` to the following propert

These analyzers help to ensure that a library is compatible with Native AOT.

### Multi-targeting for AOT compatibility

When preparing libraries for AOT compatibility, if your library targets any framework earlier than `net8.0` (such as `netstandard2.0`, or `net472`), multi-target to `net8.0`. This ensures that apps targeting `net8.0` or above get a version of your library that supports the AOT analyzers. Also, include the latest .NET version so your library is analyzed with the latest analyzer. Use the `IsTargetFrameworkCompatible` MSBuild function to conditionally enable `IsAotCompatible` for `net8.0` and above:

```xml
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net8.0;net10.0</TargetFrameworks>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</IsAotCompatible>
</PropertyGroup>
```

For more information, see [Trimming may not be used with .NET Standard or .NET Framework](../../compatibility/sdk/8.0/trimming-unsupported-targetframework.md).

## Native debug information

By default, Native AOT publishing produces debug information in a separate file:
Expand Down
15 changes: 14 additions & 1 deletion docs/core/deploying/trimming/prepare-libraries-for-trimming.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Prepare .NET libraries for trimming
description: Learn how to prepare .NET libraries for trimming.
author: sbomer
ms.author: svbomer
ms.date: 06/12/2023
ms.date: 11/20/2025
---

# Prepare .NET libraries for trimming
Expand Down Expand Up @@ -90,6 +90,19 @@ Follow the preceding pattern for multiple libraries. To see trim analysis warnin
* Even if there were no API changes.
* Introducing trim analysis warnings is a breaking change when the library is used with `PublishTrimmed`.

## Multi-targeting for trimming

When preparing libraries for trimming, if your library targets any framework earlier than `net6.0` (such as `netstandard2.0`, or `net472`), multi-target to `net6.0`. This ensures that apps targeting `net6.0` or above get a version of your library that supports the trim analyzer. Also, include the latest .NET version so your library is analyzed with the latest analyzer. Use the `IsTargetFrameworkCompatible` MSBuild function to conditionally enable `IsTrimmable` for `net6.0` and above:

```xml
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net10.0</TargetFrameworks>
<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
</PropertyGroup>
```

For more information, see [Trimming may not be used with .NET Standard or .NET Framework](../../compatibility/sdk/8.0/trimming-unsupported-targetframework.md).

## Resolve trim warnings

The preceding steps produce warnings about code that might cause problems when used in a trimmed app. The following examples show the most common warnings with recommendations for fixing them.
Expand Down
4 changes: 2 additions & 2 deletions docs/core/tools/sdk-errors/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ This list is a complete list of the errors that you might get from the .NET SDK
|NETSDK1207|Ahead-of-time compilation is not supported for the target framework.|
|NETSDK1208|The target platform identifier {0} was not recognized. This is because MSBuildEnableWorkloadResolver is set to false which disables .NET SDK Workloads which is required for this identifier. Unset this environment variable or MSBuild property to enable workloads.|
|NETSDK1209|The current Visual Studio version does not support targeting {0} {1}. Either target {0} {2} or lower, or use Visual Studio version {3} or higher.|
|NETSDK1210|IsAotCompatible and EnableAotAnalyzer are not supported for the target framework. Consider multi-targeting to a supported framework to enable ahead-of-time compilation analysis, and set IsAotCompatible only for the supported frameworks. For example:<br>`<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '{0}'))>true</IsAotCompatible>`|
|NETSDK1210|IsAotCompatible and EnableAotAnalyzer are not supported for the target framework. Consider multi-targeting to a supported framework to enable ahead-of-time compilation analysis, and set IsAotCompatible only for the supported frameworks. For example:<br>`<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</IsAotCompatible>`|
|NETSDK1211|EnableSingleFileAnalyzer is not supported for the target framework. Consider multi-targeting to a supported framework to enable single-file analysis, and set EnableSingleFileAnalyzer only for the supported frameworks. For example:<br>`<EnableSingleFileAnalyzer Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '{0}'))">true</EnableSingleFileAnalyzer>`|
|NETSDK1212|IsTrimmable and EnableTrimAnalyzer are not supported for the target framework. Consider multi-targeting to a supported framework to enable trimming, and set IsTrimmable only for the supported frameworks. For example:<br>`<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '{0}'))">true</IsTrimmable>`|
|NETSDK1212|IsTrimmable and EnableTrimAnalyzer are not supported for the target framework. Consider multi-targeting to a supported framework to enable trimming, and set IsTrimmable only for the supported frameworks. For example:<br>`<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>`|
|NETSDK1213|Targeting .NET 8.0 or higher in Visual Studio 2022 17.7 is not supported.|