MSBuild: Key file importing error

Sometimes you have to sign with an existing key file building .NET project assembly through console msbuild.exe

There is manual way to import key file without installed Visual Studio.

MSBuild message:

Error MSB3325: Cannot import the following key file: keyfile.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_XXXXXXXXXXXXXXX.

Here is the solution:

  1. Check user has administrator rights from command line:
  2. > net localgroup Administrators
  3. Change dir to the keyfile.pfx directory.
  4. Execute the following tool with command:
  5. > sn.exe  -i  keyfile.pfx VS_KEY_XXXXXXXXXXXXXXX

sn.exe location example: %PROGRAMFILES%\Microsoft Visual Studio 8\SDK\v2.0\Bin

This entry was posted in Programming and tagged , , , , . Bookmark the permalink.

Leave a comment