I have a VSTO add-in which I'm migrating from VS2010 to visual studio 2019. However, I forgot the password to mypfx key attached to the main project of the solution.
I'm now trying to create a new one and import it into my project to replace the old key which I can't use anymore. I've tried subsequent steps indicated on stackoverflow and other sites, but I keep getting the following build error in VS2019:
Cannot import the following key file: newtest.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_10580C0D68F0E891 <project name>
However, that's exactly what I'm trying. First, I create a new certificate as indicated here:
New-SelfSignedCertificate -DnsName "somename" -CertStoreLocation "cert:\LocalMachine\My"
Then I export it :
$CertPassword = ConvertTo-SecureString -String “somepass” -Force –AsPlainText
Export-PfxCertificate -Cert cert:\LocalMachine\My\<somethumbprint> -FilePath <path>/newtest.pfx -Password $CertPassword
Final step, as in this question is to use sn.exe with the following command:
sn -i sg newtest.pfx VS_KEY_XXXXXXXXXXXX
The command runs successfully, but when I restart vs2019 again and open the add-in solution, the samen error pops up again. What can I do?
EDIT Also, I cannot uncheck the "sign clickonce manifest" checkbox in Project > Properties > Signing. THis means that the Select from store option as mentioned in the answer below is unavailable. I have moved this project to another computer, could that be the cause?
A bit stuck here.