I have a software that must be signed by a pfx certificate during the build. The machine on which I build the solution is a fresh new machine and we are trying to not perform any configuration by hand but only via scripts during the build process.
When I launch the build I get this error from msbuild
[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5):
Error MSB3325: Cannot import the following key file: Key.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_07C5CCD85188D111
Usually I solve this by executing in the Developer Console of Visual Studio on the build machine:
sn -i VS_KEY_07C5CCD85188D111 path\to\Key.pfx
But, as told before, I would like that the build automatically retrieves the container name and imports the certificate as a step prior to the msbuild
command. The problem I have is that I don't know how to retrieve the container name Visual Studio wants to use, because it changes depending on the machine I run the build on.
Do you know how Visual Studio computes that container name? Or how to retrieve it in anyway?