在 MSBuild、Team Build 和 TFS 中使用 PFX 文件对程序集进行签名 [英] Signing assemblies with PFX files in MSBuild, Team Build, and TFS

查看:25
本文介绍了在 MSBuild、Team Build 和 TFS 中使用 PFX 文件对程序集进行签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用 Team Build 构建项目时收到此错误(MSBuild) 在 TFS 2010:

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

C:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.Common.targets (1970):
无法导入以下密钥文件:CCC.pfx.
密钥文件可能受密码保护.

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

C:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.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:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.Common.targets (1970):
已取消导入密钥文件CCC.pfx".

C:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.Common.targets (1970):
Importing key file "CCC.pfx" was canceled.

<小时>

在 Visual Studio 2010 中一切正常.程序集使用 PFX 文件.通常在 Visual Studio 中,我们在第一次构建时会提示输入密码,但之后再也不会...


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...

我试过跑步:

sn -i companyname.pfx VS_KEY_3E185446540E7F7A 

正如 Stack Overflow 问题中建议的其他回复 Cannot import the keyfile 'blah.pfx' - error 'The keyfile may be password受保护'.我已尝试按照 Stack Overflow 问题 使用 MSBuild 签署 ClickOnce 或程序集导致错误 MSB3321 中的建议导入个人证书存储区.但一切都无济于事,仍然是同样的错误.

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.

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

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?

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

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.

推荐答案

最终为我解决的问题是让 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.

这篇关于在 MSBuild、Team Build 和 TFS 中使用 PFX 文件对程序集进行签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆