Visual Studio团队服务部署人员/构建证书错误 [英] Visual studio team services deploymen/buildt certificate error

查看:106
本文介绍了Visual Studio团队服务部署人员/构建证书错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VSTS中的持续集成和部署功能来构建一次单击应用程序(Visual Studio Team Services在线)我们正在尝试使用托管代理Visual Studio 2015来构建此应用程序.我们很难签署强名称密钥错误

I am trying to build a click-once application using the Continuous integration and deployment feature in VSTS (Visual studio team services Online)We are trying to build this using the Hosted agent Visual studio 2015 We had difficulties signing the strong name key file with an error of

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.

我试图从存储中选择文件,也从文件中选择了改变位置,并确保提交但没有成功. 我如何克服这个错误或做错了什么的任何想法.

I have tried to both select from store and from file changed the location and made sure to commit but with no success. Any ideas how i can overcome this errors or what am doing wrong.

已选择答案的答案

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

Just wanted to make a clarification if anyone else has the same issue, in addition to the answer i had to place my certificate in my source control code and commit it. Then to select its location add a global variable on the VSTS Build

$cert.Import("$(CertPath)", $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet") $(CertPath)类似于$(Build.SourcesDirectory)\SharedSolutionFiles\CertificateName.pfx

$cert.Import("$(CertPath)", $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet") Where $(CertPath) would be something like $(Build.SourcesDirectory)\SharedSolutionFiles\CertificateName.pfx

推荐答案

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

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.

在没有PowerShell导入证书步骤的情况下构建失败:

Build failed without PowerShell Import Certificate Step:

通过PowerShell导入证书传递的内部版本:

Build passed with PowerShell Import Certificate Step:

我使用的PowerShell脚本:

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

这篇关于Visual Studio团队服务部署人员/构建证书错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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