Tuesday, May 16, 2017

Cannot import the following key file. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate

I got an error when compiling a project in TeamCity. This particular project had assemblies signed. TeamCity threw an error that said:

Cannot import the following key file. 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_FFA0xxxxx

The fix to this problem is quite simple:

1) Open the Developer Command Prompt for VS 2017
2) Type:

     sn -i "c:\path to your pfx\file.pfx" VS_KEY_xxxxxx

where the VS_KEY is what Team City said