Visual studio team services deploymen/buildt certificate error

余生颓废 提交于 2019-11-27 05:29:24

You can create a PowerShell script and add a PowerShell Script step in your build definition to import the certificate file before the VSBuild step.

Build failed without PowerShell Import Certificate Step:

Build passed with PowerShell Import Certificate Step:

The PowerShell Script I used:

$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()

The better way is that you can setup a on premise build agent and import the certificate to certificate store, then change build agent service account to the same account.

Instead of using either an on premise build or loading the certificates on to the certificate stores on the build agent (which could be considered insecure) it is possible to overwrite the build task FileSign and construct one that uses a certificate file and password.

I have outlined the steps here: https://stackoverflow.com/a/55313239/2068626

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!