Skip to content

MSBuild: Custom Target after Publish runs before AoT binary is in publish directory #39549

Open
@darinkes

Description

@darinkes

In a project we switched from SelfContained to PublishAot.
This project wants to sign the published executable in the end.

The Target looks something like this:

  <Target Name="SignAfterPublish" AfterTargets="Publish" Condition="''$(RuntimeIdentifier)'=='win-x64' AND '$(Configuration)'=='Release'">
    <Message Text="Signing $(MSBuildProjectDirectory)\$(PublishDir)\$(TargetName)$(NativeBinaryExt)"/>
    <Exec Command="signtool &quot;$(MSBuildProjectDirectory)\$(PublishDir)\$(TargetName)$(NativeBinaryExt)&quot;"/>
  </Target>

The filepath got changed from $(PublishedSingleFilePath) to $(MSBuildProjectDirectory)\$(PublishDir)\$(TargetName)$(NativeBinaryExt) for the AoT build.

With PublishAot the file in the publish directory is not the AoT binary, when AfterPublish gets called.
It seems its the executable from the folder above publish. Its 300 KB, while the AoT Binary is 40 MB.
The AoT binary is placed in the publish folder after the AfterPublish runs.

Is there a new Target to hook into for this?
At least couldn't find any PublishAoT-Targets in the sources.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-NativeAOTNative AOT compilationuntriagedRequest triage from a team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions