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

编程入门 行业动态 更新时间:2024-10-23 21:38:25
本文介绍了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团队服务部署人员/构建证书错误

本文发布于:2023-11-14 00:02:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585658.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:证书   团队   错误   人员   Visual

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!