Feb 12 2022
08:52 AM
- last edited on
Mar 05 2024
01:30 PM
by
TechCommunityAP
Feb 12 2022
08:52 AM
- last edited on
Mar 05 2024
01:30 PM
by
TechCommunityAP
I have the following YAML
# .NET Desktop # Build and run tests for .NET Desktop or Windows classic desktop solutions. # Add steps that publish symbols, save build artifacts, and more: # https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net trigger: - master pool: vmImage: 'windows-latest' variables: - group: 'CertPass' steps: - task: DownloadSecureFile@1 displayName: Download Pfx name: myCertificatePfx inputs: secureFile: ventasmlcert.pfx - task: DownloadSecureFile@1 displayName: Download sni name: snInstallPfx inputs: secureFile: SnInstallPfx.exe - task: PowerShell@2 env: SN_INSTALL_PFX: $(snInstallPfx.secureFilePath) MYCERTIFICATE_PFX: $(myCertificatePfx.secureFilePath) MYCERTIFICATE_PFX_PASSWORD: $(certpass) inputs: targetType: 'inline' script: '&"$($ENV:SN_INSTALL_PFX)" "$($ENV:MYCERTIFICATE_PFX)" "$($ENV:MYCERTIFICATE_PFX_PASSWORD)"' - task: NuGetToolInstaller@1 - task: NuGetCommand@2 inputs: restoreSolution: '$(solution)' - task: VSBuild@1 displayName: 'Build .csproj file' inputs: solution: '$(solution)' platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' - task: VSTest@2 inputs: platform: '$(buildPlatform)' configuration: '$(buildConfiguration)'
Because my solution has different projects that are strongly signed with a PFX certificate I have first to add the certificate to the machine. Then the solution build happens but what I saw is that the Container name for the Certificate task is different for every project that is built.
When I run the PowerShell script for the certificate the output is:
The key pair has been installed into the strong name CSP key container 'VS_KEY_2211CE6F0D92996F'. VS_KEY_2211CE6F0D92996F Finishing: PowerShell
And in the solution build task I get errors related to the PFX because it couldn't be found because every project compilation seems to be running on different containers:
Project A error:
Error MSB3325: Cannot import the following key file: ***cert.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_71452E506F1E61FB
Project B error:
Error MSB3325: Cannot import the following key file: ***cert.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_1789CEF560C2266D
So if you see the Powershell executes the certificate in a conatiner VS_KEY_2211CE6F0D92996F, then Project A is compiled in a container VS_KEY_71452E506F1E61FB and Project B in a container VS_KEY_1789CEF560C2266D
Any clue on how to make all my tasks execute in the same container?
Mar 27 2023 06:57 AM
@alexvazquez I have the same issue - did you manage to resolve?