Skip to content

PublishAOT property causes build failure when used with earlier TFMS in TargetFrameworks property #30814

Closed
@agocke

Description

@agocke

Repro:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>

Now publish with ~/tmp/dn/dotnet.exe publish -r win-x64 -p:PublishAot=true -f net8.0

This should work because PublishAot is valid for net8.0 and we're passing -f net8.0 to only target that TFM. But it appears at least some logic is being executed for net6.0 regardless.

This will also fail if you place PublishAot in the project file unconditionally and then run publish --sc -r win-x64 -f net8.0.

In both of these cases, we should somehow guard against the PublishAot flag being propagated through in unsupported TFMs, or fix framework targeting to run no logic for alternate TFMs when specified with -f.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions