3

In Visual Studio 2019, you can define events to be run after BUILD ("Post-build"), but can you define also an event after PUBLISH?

I am publishing a .net 5 single-file (Windows Desktop App), which is in fact an exe file. I want to digitally sign the exe with a tool before it is finally released. How can I automate this?

askolotl
  • 964
  • 1
  • 13
  • 27
  • Does this answer your question? [After Publish event in Visual Studio](https://stackoverflow.com/questions/13781799/after-publish-event-in-visual-studio) – omajid Aug 23 '21 at 13:02

1 Answers1

1

you can use msbuild target to execute a task after the project is published and invoke a command to sign you executable file.

edit you csproj file and add the following msbuild target

<Target Name="Sign" AfterTargets="Publish">
    <Exec WorkingDirectory="$(PublishDir)" Command="{your signing tool command here}" />
</Target>

save your file and run dotnet publish the signing command will be executed after the publish is finished

aamd
  • 397
  • 4
  • 12