msbuild - VSTS 构建失败并出现 MSB3325,无法导入 PFX key 文件

标签 msbuild azure-devops azure-pipelines azure-pipelines-build-task

我创建了一个构建定义来在visualstudio.com上在线构建一个桌面应用程序,它在任务构建解决方案(Visual Studio构建)中失败并出现以下错误,

[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脚本任务,如下所示,
[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 帖子类似于从管理员用户构建的指定解决方案,或手动安装 pfx 证书,但由于它们与个人计算机有关,我正在尝试在 visualstudio.com 上配置持续集成,它们似乎对我。

请注意,我能够在本地机器上成功构建。

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

第 1 步:创建一个新的 VSTO 插件项目(任何 Excel/Word/Powerpoint)。

第 2 步:将此附加到 VSTS。

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

STEP 4:尝试在本地机器上构建,它会成功。

第 5 步:将其推过去并尝试在 VSTS 上构建,您将得到与上述相同的错误。

最佳答案

我从“项目属性 -> 签名”页面取消选中“签署程序集”复选框,一切都像一个魅力。该版本已通过 VSTS 成功签名。不知何故,我错过了许多与该问题相关的 SO 线程中提供的解决方案。

关于msbuild - VSTS 构建失败并出现 MSB3325,无法导入 PFX key 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50063626/

相关文章:

visual-studio - 为什么在使用 Visual Studio 2017 构建解决方案时 Directory.Build.props 不起作用?

.net - 从Powershell运行MSBuild而不指定.Net版本

c# - 增加 version.props 中的数字

azure-devops - GitHub检查Azure Pipelines时如何报告管道的各个作业?

azure-devops - 当新构建排队时,如何取消所有以前的构建?

azure - 动态创建管道中特定作业的数量

visual-studio - error : The imported project was not found. 确认Import声明中的表达式正确,文件存在于磁盘上

SSIS 项目无法在自托管代理上构建

azure - 如何防止 Azure Devops 中的下一个发布管道在上一个发布管道完全完成之前启动?

tfs - 错误 'No agent could be found with the following capabilities: msbuild, visualstudio, vstest'