I have a WPF Solution I am building in VSTS Online.
Below is my basic Build Definition:
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.
What setting/step do I need to include to ensure the PFX file is seen and the password is set?
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()
Related thread: Visual studio team services deploymen/buildt certificate error