Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

Adding multi-targeting sections to trimming and AOT documentation

  • Explore repository structure and understand the issue
  • Review current documentation in prepare-libraries-for-trimming.md
  • Review related breaking change document
  • Add new H2 section "Multi-targeting for trimming" after "Enable library trim warnings"
  • Include recommendations for multi-targeting scenarios
  • Add example showing conditional IsTrimmable usage
  • Explain common multi-targeting scenarios (netstandard2.0, net472, net6.0+)
  • Link to breaking change document
  • Verify markdown linting passes
  • Update document metadata date
  • Address review feedback - simplify section to brief statement + example
  • Clarify multi-targeting recommendation to avoid TFM gaps
  • Move IsAotCompatible multi-targeting guidance to AOT docs
  • Update AOT docs to use net8.0 (earliest version with AOT compat analysis)
  • Update SDK error messages to specify net6.0 for trimming, net8.0 for AOT
  • Add recommendation to include latest .NET version for latest analyzer
  • Update examples to use net10.0 as latest version
  • Add Oxford commas to framework lists per writing style guidelines
  • Break up long sentences for better readability
  • Final review and validation

Summary

Per @sbomer's feedback:

  • Broke up long sentences in both trimming and AOT documentation sections for better readability
  • Changed structure to imperative mood: "if your library targets..., multi-target to..."
  • Split explanation into shorter, clearer sentences
  • Changed "Additionally, consider including" to "Also, include"
  • Changed "to ensure your library is analyzed" to "so your library is analyzed"
Original prompt

This section details on the original issue you should resolve

<issue_title>Prepare .NET libraries for trimming: Add multi-targeting H2 with our recommendations</issue_title>
<issue_description>
See this comment copied below

Finally, recently we've learned that multi-targeting is not only very common, but basically a must have when enabling trimming. (This is based on experience trying to make some NuGets trim compatible). I think the document should have a section about the multi-targeting and our recommendations around it. But the core point is that very few libraries will only target latest TFM. By far the most common case is either library targets netstandard2.0 or it multi-targets net472, netstandard2.0 and net6.0 (or some combination of these).


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Comments on the Issue (you are @copilot in this section)

@sbomer Leaving a note here to mention the new behavior in the `true` part of https://learn.microsoft.com/dotnet/core/deploying/trimming/prepare-libraries-for-trimming. @sbomer I'm adding a breaking change notice that mentions multi-targeting: https://github.com//pull/36775. We still need a dedicated section in the general trimming docs though. When that's added, we should also link to it from the breaking change notice.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


Internal previews

📄 File 🔗 Preview link
docs/core/deploying/native-aot/index.md docs/core/deploying/native-aot/index
docs/core/deploying/trimming/prepare-libraries-for-trimming.md docs/core/deploying/trimming/prepare-libraries-for-trimming
docs/core/tools/sdk-errors/index.md docs/core/tools/sdk-errors/index

Copilot AI changed the title [WIP] Prepare .NET libraries for trimming with multi-targeting recommendations Add multi-targeting section to trimming documentation Nov 20, 2025
Copilot AI requested a review from sbomer November 20, 2025 22:36
Copilot AI requested a review from sbomer December 2, 2025 19:22
@sbomer sbomer requested a review from a team December 2, 2025 19:39
Copilot AI requested a review from sbomer December 2, 2025 21:13
Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Add a similar note for IsAotCompatible (alongside the existing docs for that option).

Copy link
Contributor Author

Copilot AI commented Dec 2, 2025

@copilot Add a similar note for IsAotCompatible (alongside the existing docs for that option).

Added in 78f6612. The note directs users to apply the same multi-targeting guidance when using IsAotCompatible in multi-targeted projects, with a link to the "Multi-targeting for trimming" section.

Copilot AI requested a review from sbomer December 2, 2025 21:51
Copilot AI requested a review from sbomer December 4, 2025 23:06
@sbomer sbomer marked this pull request as ready for review December 4, 2025 23:12
@sbomer sbomer requested review from a team and meaghanlewis as code owners December 4, 2025 23:12
Copilot AI review requested due to automatic review settings December 4, 2025 23:12
@sbomer sbomer requested a review from adegeo as a code owner December 4, 2025 23:12
@sbomer sbomer requested a review from a team December 4, 2025 23:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.


### 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`), you should also multi-target to `net8.0` to ensure that apps targeting `net8.0` or above get a version of your library that supports the AOT analyzers. Additionally, consider including the latest .NET version to ensure your library is analyzed with the latest analyzer. Use the `IsTargetFrameworkCompatible` MSBuild function to conditionally enable `IsAotCompatible` for `net8.0` and above:
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing Oxford comma in the list. According to the Markdown writing style guidelines, you must use the Oxford comma in all lists. Change (such as \netstandard2.0` or `net472`)to(such as `netstandard2.0`, or `net472`)` to include the comma before "or".

Copilot generated this review using guidance from repository custom instructions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Oxford comma in 603021d. Changed (such as \netstandard2.0` or `net472`)to(such as `netstandard2.0`, or `net472`)`.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@sbomer sbomer requested a review from jtschuster December 10, 2025 23:17
@sbomer sbomer enabled auto-merge (squash) December 10, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prepare .NET libraries for trimming: Add multi-targeting H2 with our recommendations

3 participants