使用 MSBuild 签署 ClickOnce 或程序集会导致错误 MSB3321

发布于 2024-07-22 11:06:56 字数 1034 浏览 0 评论 0原文

我已在 Visual Studio 2008 中设置了简单的项目,以使用 ClickOnce 安装程序。 我已指定 ClickOnce 清单应由我们公司的 PFX 文件进行签名。 当我在 Visual Studio 中进行设置时,它要求输入 PFX 文件的密码,我很乐意提供该密码。 当我在 Visual Studio 中构建和发布时,一切正常。 它也可以在我的计算机上从 MSBuild 正常构建。

但是,当我尝试在构建计算机上使用 MSBuild 构建它时,出现以下错误:

ERROR MSB3321 in 
    C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(1805,7)
    : Importing key file "ourCertificate.pfx" was canceled (sic).

经过一番搜索后,我发现了一些信息,表明这是因为我没有提供密码。 但我找不到在构建机器上提供密码的方法。 我还看到了安装 Visual Studio 的建议,并在 Visual Studio 内提供密码,然后它将在 MSBuild 中运行。 但我真的想避免在构建机器上安装 Visual Studio。

我尝试双击 PFX 文件将其导入,并在询问时输入密码,但这没有帮助。

如果我在 Visual Studio 中选中“对程序集进行签名”并提供相同的 PFX 文件,也会发生同样的情况。

我该如何解决这个问题? 是否有手动方法在构建机器上存储密码?

I've set up my simple project in Visual Studio 2008 to use a ClickOnce installer. I've specified that the ClickOnce manifests should be signed by our comapny's PFX file. When I set this up in Visual Studio it asked for the password for the PFX file, which I gladly supplied. Everything works fine when I build and publish from within Visual Studio. It also works fine building from MSBuild on my machine.

However, when I try to build it using MSBuild on our build machine, I get the following error:

ERROR MSB3321 in 
    C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(1805,7)
    : Importing key file "ourCertificate.pfx" was canceled (sic).

After some searching I've found a little bit of information that says this is because I haven't supplied the password. But I can't find a way to supply the password on the build machine. I've also seen suggestions to install Visual Studio, and supply the password once inside Visual Studio, and then it will work from MSBuild after that. But I'd really like to avoid installing Visual Studio on the build machine.

I've tried double clicking the PFX file to import it and putting in the password when asked, but this didn't help.

This same thing happens if I check 'Sign the assembly' in Visual Studio and supply the same PFX file.

How can I fix this problem? Is there a manual way of storing the password on the build machine?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

喜爱皱眉﹌ 2024-07-29 11:06:56

您可以将证书导入到构建计算机上的受信任发布者存储中吗?
(Internet Explorer > 工具 > 选项 > 内容 > 证书)

我不使用 MSBuild 来创建部署; 我用法师。 但是,我使用 .pfx 文件将我们的证书导入到我的受信任发布者商店中。 为此,我必须输入密码。 完成后,当我在 Mage 中保存清单时,我不再需要提供密码。 我只需从我的商店中选择证书即可。

Can you import your certificate into your Trusted Publisher store on the build machine?
(Internet Explorer > Tools > Options > Content > Certificates)

I don't use MSBuild to create deployments; I use Mage. However, I use our .pfx file to import our cert into my Trusted Publisher store. In order to do that I have to input the password. After that's done, when I save a manifest in Mage I no longer have to provide a password. I can simply select the cert from my store.

小鸟爱天空丶 2024-07-29 11:06:56

John Robbins 有一篇关于如何包装 的博客文章MSBuild 中的 SignTool.exe,代码签名 – 比您想象的更便宜、更容易

John Robbins has a blog post about how to wrap SignTool.exe in MSBuild, Code Signing – It’s Cheaper and Easier than You Thought.

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