VSTS生成失败,并显示MSB3325,无法导入PFX密钥文件 [英] VSTS build fails with MSB3325, Cannot import PFX key file

查看:123
本文介绍了VSTS生成失败,并显示MSB3325,无法导入PFX密钥文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个构建定义,以便在visualstudio.com上在线构建桌面应用程序,该应用程序在执行任务构建解决方案"(Visual Studio构建)时失败,并出现以下错误,

I had created a build definition to build a desktop application online on visualstudio.com which fail at task Build Solution (Visual Studio build) with following error,

[错误] C:\ Program Files(x86)\ Microsoft VisualStudio \ 2017 \ Enterprise \ MSBuild \ 15.0 \ Bin \ Microsoft.Common.CurrentVersion.targets(3156,5):错误MSB3325:无法导入以下密钥文件:Sixmod5Certificate.pfx.密钥文件可能受密码保护.至更正此问题,尝试再次导入证书或手动安装带有以下密钥的强名称CSP证书容器名称:VS_KEY_3B2BCC84AE4E26F1

[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(3156,5): Error MSB3325: Cannot import the following key file: Sixmod5Certificate.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_3B2BCC84AE4E26F1

我遵循了在 https://developercommunity.visualstudio.com/content/problem/156086/vsts-build-msb3325-cannot-import-the-following-key.html

然后按照 https://stackoverflow.com/a/48698229/3531672 中的说明进行操作我在构建任务之前添加了powershell脚本任务,如下所示,

then as specified at, https://stackoverflow.com/a/48698229/3531672 I had added a powershell script task before build task, as follows,

[CmdletBinding()]
param(  
    [Parameter(Mandatory)][string] $pfxpath,
    [Parameter(Mandatory)][string] $password
)

Add-Type -AssemblyName System.Security
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($pfxpath, $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet")
$store = new-object system.security.cryptography.X509Certificates.X509Store -argumentlist "MY", CurrentUser
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")
$store.Add($cert)
$store.Close()

但还没有运气,

有其他类似于此指定解决方案的SO帖子,可以从Admin用户构建,也可以手动安装pfx证书,但是由于它们与个人计算机有关,因此我试图在visualstudio.com上配置持续集成,因此没有对我来说似乎有用.

There are different SO post similar to this specifying solution to build from Admin user, or installing pfx certificate manually, but as they are related to personal computer and I am trying to configure Continuous integration on visualstudio.com, they don't seem useful to me.

请注意,我能够在本地计算机上成功构建.

Please note I am able to successfully build on my local machine.

如果您最终希望重新产生此问题,请按照以下步骤操作,

If you wish to regenerate this problem at your end, follow these steps,

第1步:创建一个新的VSTO外接程序项目(任何Excel/Word/Powerpoint).

STEP 1: Create a new VSTO Addin Project (Any Excel/Word/Powerpoint).

第2步:将此附加到VSTS.

STEP 2: Attach this to VSTS.

第3步:在应用程序属性"的签名"选项卡中,不要使用临时证书,而是创建一个新的受密码保护的证书(在我的情况下为PFX-个人信息交换),并使用它来签署ClickOnce清单

STEP 3: In signing tab of Application properties, instead of using temperory certificate, create a new password protected certificate (PFX - Personal Information Exchange in my case) and use this to sign ClickOnce Manifest

第4步:尝试在本地计算机上构建,它将成功.

STEP 4: Try to build on local machine, it will succeed.

第5步:将其推入并尝试在VSTS上进行构建,您将得到与上述相同的错误.

STEP 5: Push it over and try to build on VSTS, you will get the same error as above.

推荐答案

我从项目属性->签名"页面中取消选中了对程序集签名"复选框,并且一切正常.该构建已通过VSTS成功签名.不知何故,我错过了许多与该问题相关的SO线程中提供的解决方案.

I unchecked the "Sign the assembly" checkbox from the "project properties -> Signing" page and everything worked like a charm. The build was signed successfully through VSTS. Somehow I missed this solution provided in many SO threads related to the problem.

这篇关于VSTS生成失败,并显示MSB3325,无法导入PFX密钥文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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