Importing certificate from .pfx to use with MSBuild/Team Build (ResolveKeySource)

This is an issue which came up and was resolved via email. I just wanted to post it here in case it's useful for anyone else.

Original Problem

Now I wanted to automatic build a baseclass library which has a strongname (password protected) and Now the build process fails with

MyBuils.fbp6 : Action error "Build VS.Net Solution [ MySolution.sln ]": ERROR MSB4018 in C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(1783,7) : The "ResolveKeySource" task failed unexpectedly.

I think this is because the BuildServer doesn't know the password for the project pfx. so what do I have to do here?

Unfortunately there is no full visual studio on the webserver (only the Teamexplorer)

 

Reply/Solution

In order to access the key in the pfx file without requiring a password, it needs to be imported into the certificate store for the Team Build user on the build machine.

To do this, first log into the build machine as the user who TFS Build runs as (normally this is TFSSERVICE, but it may differ in your case.)

Find the .pfx file for the project that you need to sign (you may need to  retrieve it from source control using Source Explorer.)

Double-click the .pfx file and it should open the "Certificate Import Wizard".

Follow through the wizard, entering the password for the .pfx file. DO NOT check the "enable strong private key protection" checkbox.

... once this step finished, TeamBuild/FinalBuilder/MSBuild should be able to access the key from the certificate store, without requiring a password.