在 MSBuild、Team Build 和 TFS 中使用 PFX 文件对程序集进行签名

发布于 2024-09-29 17:22:05 字数 1445 浏览 1 评论 0原文

尝试使用 Team Build (MSBuild) TFS 2010:


C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (1970):
无法导入以下密钥文件:CCC.pfx。
密钥文件可能受密码保护。

要更正此问题,请尝试再次导入证书或手动将证书安装到具有以下密钥容器名称的强名称 CSP:VS_KEY_C00C673BBB353901

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (1970):
导入密钥文件“CCC.pfx”已被取消。


在 Visual Studio 2010 中一切构建正常。程序集使用 PFX 进行签名文件。通常在 Visual Studio 中,我们第一次构建时会被提示输入密码,但之后就不会再出现了...

我尝试运行:

sn -i companyname.pfx VS_KEY_3E185446540E7F7A 

如 Stack Overflow 问题中建议的其他回复无法导入密钥文件“blah.pfx”-错误“密钥文件可能受密码保护”。我已尝试按照 Stack Overflow 问题中的建议导入个人证书存储使用 MSBuild 签署 ClickOnce 或程序集会导致错误 MSB3321。但都没有效果,还是同样的错误。

我该怎么做?我是否必须以某种方式将证书添加到构建服务运行的 Windows 帐户或类似的东西?

或者,如何使在 Team Build 中完成的构建不使用签名?我只想检查它是否编译并运行单元测试。我不需要为此签名。

I get this error when trying to build a project using Team Build (MSBuild) on TFS 2010:


C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (1970):
Cannot import the following key file: CCC.pfx.
The key file may be password protected.

To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_C00C673BBB353901

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (1970):
Importing key file "CCC.pfx" was canceled.


It all builds OK in Visual Studio 2010. The assembly is signed with a PFX file. Usually in Visual Studio we are prompted for the password the first time we build, but then never again...

I've tried running:

sn -i companyname.pfx VS_KEY_3E185446540E7F7A 

as other replies as suggested in Stack Overflow question Cannot import the keyfile 'blah.pfx' - error 'The keyfile may be password protected'. I've tried importing into the personal certificate store as suggested in Stack Overflow question Using MSBuild to sign ClickOnce or assembly results in error MSB3321. But all to no avail, still the same error.

How do I do it? Do I have to somehow add the certificate to the Windows account the build service runs under or something like that?

Alternatively, how do I make the build done in Team Build not use signing? I just want to check it compiles and run the unit tests. I don't need signing for that.

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

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

发布评论

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

评论(6

太阳男子 2024-10-06 17:22:05

您需要调整 这个答案 根据您的具体情况。像这样的东西:

sn -i companyname.pfx VS_KEY_C00C673BBB353901

You need to adapt this answer to your specific. Something like:

sn -i companyname.pfx VS_KEY_C00C673BBB353901
很酷不放纵 2024-10-06 17:22:05

我所做的不是那么优雅,但是有效:以在构建计算机上运行 msbuild 的用户身份登录,手动调用 msbuild,然后在出现提示时输入密码。它现在将保存在该用户的证书存储中,并且现在构建可以在无人值守的情况下运行。

What I did is not that elegant, but works: log in as the user that runs msbuild on the build machine, manually invoke msbuild, and then type in the password when prompted. It'll now be saved in that user's certificate store, and now the builds can run unattended.

几味少女 2024-10-06 17:22:05

最终为我解决的问题是让 TFS Build 服务在本地计算机上以管理员身份运行的帐户。

但不知道我之前尝试过的其他事情是否也需要完成才能使其正常工作。但是在成为管理员之前它不起作用,在成为管理员之后它起作用了。

What finally fixed it for me was making the account under which TFS Build service runs an administrator on the local machine.

Don't know though if any of the other stuff I was trying before also needs to be done to get it working. But before it was admin it didn't work after it became admin it worked.

你げ笑在眉眼 2024-10-06 17:22:05

我遇到了同样的错误,在阅读了您的“管理员”评论后 - 我刚刚以管理员身份运行 VS 命令提示符,现在它工作正常。

I was getting the same error, and after reading your "administrator" comment - I just ran VS Command Prompt as Admin and it now works fine.

又怨 2024-10-06 17:22:05

我遇到了类似的问题

场景1:在本地系统中构建项目时

在我的例子中,当我从TFS下载项目并构建它时,我收到了清单签名错误。

为了避免这个问题,我右键单击了项目==>;属性==>签约
然后取消选中“签署 ClickOnce 清单”

或者

您可以单击从商店中选择按钮,然后从打开的对话框中选择您的登录 ID。

或者

您可以手动安装 PFX 文件,然后单击“更多选项”按钮来安装这些证书。

场景 2:- 构建期间出现清单错误

为了解决此错误,我首先单击从商店中选择按钮,然后从对话框中选择我的登录 ID。然后我将该项目提交到先TFS,然后运行构建。

I have faced similar issue

Scenario 1: While building project in local system

In my case i was getting the manifest signing error once i download the project from TFS and build it.

To avoid this issue I right clicked on the project ==> Properties ==> Signing
then unchecked "Sign the ClickOnce Manifests"

OR

You can click Select from store button and select your login id from the dialog box open.

OR

You can install the PFX file manually and later click on More Options button to install those certificate.

Scenario 2:- Manifest error during Build

Here to resolve this error i first clicked Select from store button and select my login id from the dialog box .Then I committed that project in TFS first and then run the build.

Oo萌小芽oO 2024-10-06 17:22:05

我有以下设置:

<PropertyGroup>
  <SignAssembly>false</SignAssembly>
  <AssemblyOriginatorKeyFile>MyKey.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>

程序集签名已关闭,但 AssemblyOriginatorKeyFile 在清单签名期间导致错误。删除了 AssemblyOriginatorKeyFile 来修复它。

I had following settings:

<PropertyGroup>
  <SignAssembly>false</SignAssembly>
  <AssemblyOriginatorKeyFile>MyKey.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>

Assembly signing was turned off, but AssemblyOriginatorKeyFile caused error during manifest sign. Removed AssemblyOriginatorKeyFile to fix it.

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