0
votes

I have been trying to create a build pipeline in Azure DevOps. While I am able to build a basic console app project, I have been getting issues when I added pfx files into the project app.

The console app project has been enabled for ClickOnce, which required to have a *.pfx key file.

When I set a basic build pipeline, but it appears to keep on failing. I get this message:

Error MSB3325: Cannot import the following key file: [XXXX].pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_FE357D179B4A2D91

error MSB3325: Cannot import the following key file: [XXXX].pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_FE357D179B4A2D91

How do I import the pfx to get the build to succeed? Appreciate any insights/directions for this.

Thanks.

1
Hi the.herbert, any update on this issue, did you get a chance to implement the solution that Bevan suggested? Were you able to resolve?PatrickLu-MSFT

1 Answers

1
votes

If you're making your PFX file available to the pipeline just add a Powershell task before the main task

#Import the PFX certificate file and password. Read the thumbprint into variable
$Thumbprint = (Import-PfxCertificate -CertStoreLocation Cert:\CurrentUser\My -FilePath Certificate.pfx -Password $pwd).Thumbprint

Write-Host $Thumbprint

#Rest of Script below or set environment variable for rest of Pipeline
Write-Host "##vso[task.setvariable variable=Thumbprint]$Thumbprint"

If you need it, you can pass the thumbprint to the rest of the pipeline with the last line or you can hard code the thumbprint where required.

I store my certificates in Azure KeyVault. If you do/would like to do the same, I have a post here for it: Access certificate thumprint from Azure DevOps variable group connected to Key vaults