如何在 Visual Studio 中的构建过程中对输出可执行文件进行签名?
当我使用项目属性中指示的强名称密钥文件
时,它要求所有引用的程序集也使用此类类似的签名。
但我想要的是使用 WinDDK Signtool.exe
进行签名。我已经手动执行此操作,但我还想调试签名程序集,最好的方法是将签名包含在构建中,可能作为 AfterBuild
步骤。
问题是我不知道如何创建 AfterBuild
步骤
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你在这里把事情搞混了。强名称与使用signtool.exe 添加到二进制文件的证书不同。也不要求依赖程序集具有证书或需要匹配。签署调试版本也没有意义,只有您的客户对其感兴趣。您已经知道您可以相信自己。
msbuild 已支持运行 sn.exe 为程序集指定强名称。
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.
我必须将以下行添加到
*.csproj
文件中:然后我将一个
sign.bat
文件添加到项目根文件夹中,我在 一些博客
I had to add the following lines to the
*.csproj
file:And then I added a
sign.bat
file to the project root folderI found this solution at some blog
在项目的属性中>> 构建活动>> 构建后事件命令行
if
条件仅在需要时签署Release。In Properties of your project >> Build Events >> Post-build event command line
The
if
condition only signs the Release if needed.