Skip to content

PublishAot doesn't respect TreatWarningsAsErrors #94178

@eerhardt

Description

@eerhardt

Description

When publishing an app for AOT, and TreatWarningsAsErrors=true, if there are trim/AOT warnings, the publish doesn't fail as errors.

However, when I <PublishTrimmed>true</PublishTrimmed> the same app (with the same trimming warnings), the publish fails.

We should be consistent in our behavior between these 2 publish operations and TreatWarningsAsErrors.

Reproduction Steps

In your .csproj:

    <PublishAot>true</PublishAot>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>

And have trim warnings in your app.

Expected behavior

The publish should fail because I have warnings and TreatWarningsAsErrors=true.

Actual behavior

The trim/AOT warnings are emitted as warnings, but these warnings were not treated as errors, and my publish succeeds.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

cc @vitek-karas @agocke @MichalStrehovsky

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions