Visual Studio团队服务部署/构建证书错误

Har*_*rry 6 azure-devops azure-pipelines-build-task azure-pipelines

我正在尝试使用VSTS中的持续集成和部署功能构建一次性点击应用程序(Visual Studio团队服务在线)我们正在尝试使用Hosted代理构建这个Visual Studio 2015我们在使用一个强名称密钥文件签名时遇到了困难的错误

MSB3326: Cannot import the following key file: xxxx.snk. The key file may be password protected. To correct this, try to import the certificate again or import the certificate manually into the current user's personal certificate store. 在那之后

MSB3321: Importing key file "xxxx.pfx" was canceled.

我试图从商店和文件中选择更改位置并确保提交但没有成功.任何想法我如何克服这些错误或做错了什么.

选择答案的Clerification

只是想澄清是否有其他人有同样的问题,除了答案我必须将我的证书放在我的源代码控制代码中并提交它.然后选择其位置在VSTS Build上添加一个全局变量

在此输入图像描述

$cert.Import("$(CertPath)", $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet") 其中$(CertPath)就像是 $(Build.SourcesDirectory)\SharedSolutionFiles\CertificateName.pfx

Edd*_*SFT 9

您可以在构建定义中创建PowerShell脚本并添加PowerShell脚本步骤,以在VSBuild步骤之前导入证书文件.

没有PowerShell导入证书的构建失败步骤: 在此输入图像描述

使用PowerShell导入证书传递构建步骤: 在此输入图像描述

我使用的PowerShell脚本:

$pfxpath = 'pathtoees.pfx'
$password = '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()
Run Code Online (Sandbox Code Playgroud)


归档时间:

查看次数:

3432 次

最近记录:

7 年,1 月 前