I am able to sign an MSIX file within the VSBuild task when using a code signing certificate (*.PFX) that is stored as a secure file from the Build Pipeline's library section using the following setup (truncated for brevity):
Note: The key is how we are assigning the p:PackageCertificateKeyFile argument.
- task: AzureKeyVault@2
inputs:
azureSubscription: 'Dev (SomeGuid)'
KeyVaultName: 'SomeKeyVault'
SecretsFilter: 'SomeCertPassword'
RunAsPreJob: false
- task: DownloadSecureFile@1
name: signingCert
inputs:
secureFile: 'SomeCertName.pfx'
- task: VSBuild@1
inputs:
platform: '$(buildPlatform)'
solution: '$(solution)'
configuration: '$(buildConfiguration)'
msbuildArgs: '
/p:AppInstallerUri=$(msixInstallUrl)
/p:AppxBundle=Never
/p:AppxBundlePlatforms="$(buildPlatform)"
/p:AppxPackageDir="$(Build.ArtifactStagingDirectory)/"
/p:AppxPackageSigningEnabled=true
/p:GenerateAppInstallerFile=true
/p:PackageCertificateThumbprint=""
/p:PackageCertificateKeyFile="$(signingCert.secureFilePath)"
/p:PackageCertificatePassword="$(SomeCertPassword)"
/p:UapAppxPackageBuildMode=SideLoadOnly
'
However, as an alternative to storing the code signing certificate within the secure files section of the pipeline library, I would like to store it in the Key Vault's certificate section and then just retrieve that within the AzureKeyVault task. So, the YAML would look something like this (truncated for brevity):
- task: AzureKeyVault@2
inputs:
azureSubscription: 'Dev (SomeGuid)'
KeyVaultName: 'SomeKeyVault'
SecretsFilter: 'SomeCertName,SomeCertPassword'
RunAsPreJob: false
- task: VSBuild@1
inputs:
platform: '$(buildPlatform)'
solution: '$(solution)'
configuration: '$(buildConfiguration)'
msbuildArgs: '
/p:AppInstallerUri=$(msixInstallUrl)
/p:AppxBundle=Never
/p:AppxBundlePlatforms="$(buildPlatform)"
/p:AppxPackageDir="$(Build.ArtifactStagingDirectory)/"
/p:AppxPackageSigningEnabled=true
/p:GenerateAppInstallerFile=true
/p:PackageCertificateThumbprint=""
/p:PackageCertificateKeyFile="$(SomeCertName)"
/p:PackageCertificatePassword="$(SomeCertPassword)"
/p:UapAppxPackageBuildMode=SideLoadOnly
'
The reason for wanting to do it this way is because I get cannot find *.appinstaller file when I try to run a separate MSIX Code Signing task. It just seems simpler and easier to sign the package within the same build task.
But, I get the following error:
Error APPX0104: Certificate file '***' not found. C:\Program Files (x86)\Microsoft Visual
From what I can tell, when the certificate file is retrieved from the AzureKeyVault task variable, it is stored as a string as opposed to a file. But, the MSBuild task is expecting a file. I have tried searching all over the web and tried some Powershell scripts to convert the imported AzureKeyVault task variable from string to base64, but I am having no luck (see links below for reference). I have literally tried about 40 different ways of doing this and I'm afraid that an attempt to list them would only confuse the question. As a result, I felt it better to present what I am trying to do and ask if it is even possible, and if yes, how?