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

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

问题描述

我正在尝试使用 VSTS(Visual Studio 在线团队服务)中的持续集成和部署功能构建一个单击一次应用程序我们正在尝试使用托管代理 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:无法导入以下密钥文件:xxxx.snk.密钥文件可能受密码保护.要解决此问题,请尝试再次导入证书或手动将证书导入当前用户的个人证书存储区.在那之后

MSB3321:导入密钥文件xxxx.pfx"被取消.

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

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)SharedSolutionFilesCertificateName.pfx

$cert.Import("$(CertPath)", $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet") Where $(CertPath) would be something like $(Build.SourcesDirectory)SharedSolutionFilesCertificateName.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天全站免登陆