VSTS Online-使用ClickOnce签名PFX密码构建解决方案 [英] VSTS Online - Build Solution With ClickOnce Signing PFX Password

查看:85
本文介绍了VSTS Online-使用ClickOnce签名PFX密码构建解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在VSTS Online中构建的WPF解决方案.

I have a WPF Solution I am building in VSTS Online.

以下是我的基本构建定义:

Below is my basic Build Definition:

在本地的Visual Studio 2017中,我已分配了一次单击认证(PFX).一切都可以在本地构建和编译.

In Visual Studio 2017 locally I've assigned a Click Once Certification (PFX). Everything builds and compiles fine locally.

构建失败,并出现以下错误:

The Build fails with the following error:

无法导入以下密钥文件:.密钥文件可能是密码 受保护的.若要更正此问题,请尝试再次导入证书,或者 将证书手动导入到当前用户的个人信息中 证书存储.

Cannot import the following key file: . 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.

我需要包括什么设置/步骤以确保可以看到PFX文件并设置了密码?

What setting/step do I need to include to ensure the PFX file is seen and the password is set?

推荐答案

使用以下代码导入证书文件(PowerShell任务):

Using this code to import certificate file (PowerShell task):

$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团队服务部署人员/构建证书错误

这篇关于VSTS Online-使用ClickOnce签名PFX密码构建解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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