1

I have a solution that contains a console (or Winform) application and I use Visual Studio publish to folder.

My problem is that we need to sign (certify) the *.EXE file. Currently I do that manually. I'm not using ClickOnce and no setup-project.

Is there a way to publish to folder and sign the resulting *.exe file at once?

W1353R
  • 21
  • 5

1 Answers1

1

Use "SignTool" to sign: https://learn.microsoft.com/en-us/dotnet/framework/tools/signtool-exe

Edit your *.csproj file and add code like this:

<Target Name="CustomAfterPublish" AfterTargets="Publish">
            <Message Text="Sign Publish EXE"      />
            <Exec Command="call c:\SignTool\signtool.exe sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /f c:\YourSingFolder\YourCertificate.pfx $(PublishDir)$(TargetName).exe" />
</Target>

Some background information here: After Publish event in Visual Studio.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
W1353R
  • 21
  • 5