How to sign the output executable during the build process in Visual Studio?

自作多情 提交于 2020-01-06 05:11:51

问题


When I use a strong name key file as indicated in the project properties, it requires that all referenced assemblies to also use such a similar signature.

But what I want is to sign using the WinDDK Signtool.exe. This I already do manually, but I also want to debug sign assemblies, and the best way of doing that is including the signature in the build, probably as a AfterBuild step.

The problem is I don't know how to create a AfterBuild step


回答1:


You are mixing things up here. A strong name is not the same thing as the certificate that's added to a binary with signtool.exe. There is also no requirement that dependent assemblies have a certificate or that it needs to match. Nor does it make sense to sign a debug build, only your customer is interested in it. You already know that you can trust yourself.

Running sn.exe to give an assembly a strong name is already supported by msbuild.




回答2:


I had to add the following lines to the *.csproj file:

<Target Name="AfterBuild">
   <Exec Command="sign.bat" />
</Target>

And then I added a sign.bat file to the project root folder

I found this solution at some blog



来源:https://stackoverflow.com/questions/4386726/how-to-sign-the-output-executable-during-the-build-process-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!