Skip to content

Unexpected NETSDK1210 after removing TFM #40870

Open
@MihaZupan

Description

@MihaZupan

Describe the bug

When using IsAotCompatible in a library that targets multiple TFMs, the NETSDK1210 warning appears after removing a TFM.

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:
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>

To Reproduce

  • Create an empty class library project
  • Set the TFMs and mark as AOT compatible
    <TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
    <IsAotCompatible>true</IsAotCompatible>
  • Build and observe no warnings
  • Remove the 7.0 target: <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
  • Build and observe a NETSDK1210 warning

Further technical details

  • SDK 9.0.100-preview.3.24204.13

While we can workaround the issue as hinted in the warning message, is it expected that this would show up after removing the 7.0 TFM, even though you still have 8.0?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions