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

查看:21
本文介绍了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天全站免登陆