about a dozen projects in my VS solution have the same line:
<PostBuildEvent>
<Command>signtool sign /f ..\Certificates\MyCert.pfx /fd sha256 "$(TargetPath)"</Command>
</PostBuildEvent>
I know that since it is using msbuild, there is a way to have a common target and have each projects reference this but I am struggling to come up with the exact syntax for this.
Create a new file, let’s call it CommonDefinitions.targets, with the following content:
Then in each file that you want to override the PostBuildEvent, add this line:
If you want to merge that with custom post-build steps, you will add additional target to the post-build by overriding PostBuildEventDependsOn. E.g.:
and