如何在 Visual Studio 中的构建过程中对输出可执行文件进行签名?

发布于 2024-10-06 07:16:33 字数 237 浏览 0 评论 0原文

当我使用项目属性中指示的强名称密钥文件时,它要求所有引用的程序集也使用此类类似的签名。

但我想要的是使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

幻梦 2024-10-13 07:16:33

你在这里把事情搞混了。强名称与使用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.

绝對不後悔。 2024-10-13 07:16:33

我必须将以下行添加到 *.csproj 文件中:

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

然后我将一个 sign.bat 文件添加到项目根文件夹中,

我在 一些博客

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

夜夜流光相皎洁 2024-10-13 07:16:33

在项目的属性中>> 构建活动>> 构建后事件命令行

if $(Configuration) == Release C:\"Program Files (x86)"\"Windows Kits"\10\bin\10.0.22621.0\x64\signtool.exe sign /tr http://timestamp.globalsign.com/tsa/r6advanced1 /td sha256 /fd sha256 /a $(TargetPath)

if 条件仅在需要时签署Release

In Properties of your project >> Build Events >> Post-build event command line

if $(Configuration) == Release C:\"Program Files (x86)"\"Windows Kits"\10\bin\10.0.22621.0\x64\signtool.exe sign /tr http://timestamp.globalsign.com/tsa/r6advanced1 /td sha256 /fd sha256 /a $(TargetPath)

The if condition only signs the Release if needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文