Skip to content

[NativeAOT] dotnet publish fails for multi-target projects #107807

@Quake4

Description

@Quake4

Description

If the project has multiple targets, then the Aot build does not work.

Reproduction Steps

Project

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net8.0-windows;net46</TargetFrameworks>
  </PropertyGroup>

</Project>

Run command
dotnet publish -r win-x64 -f net8.0-windows -c Release -p:PublishAot=true

Expected behavior

build aot

Actual behavior

Error:

  Определение проектов для восстановления...
C:\Program Files\dotnet\sdk\8.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1207: AOT-компиляция не поддерживается целевой платформой. [d:\GIT\Test\AudioAot\AudioAot.csproj::TargetFramework=net46]

Regression?

No response

Known Workarounds

Change Project to single Target

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0-windows</TargetFramework>
  </PropertyGroup>

</Project>

Configuration

net8
windows10
x64
no
no

Other information

And check main project with reference to project with other common (netstandard2.0) targets:
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks>

It should also compile correctly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions