Problems signing an assembly with a key stored in key container (VS2005)

This is one of those problems you can’t understand how could it happen.

Some background: In the past Visual Stuidio versions you were able to sign an assembly using a key stored in a file (snk) or in a safe store named key container. There were two assembly scoped attributes named AssemblyKeyFile and AssemblyKeyName respectively. I prefered the later since I didn’t have to deal with file location and the data is stored in a safe place.

Now, here comes Visual Studio 2005 with a project property page for signing assemblies (Signing tab in Project Properties) which has a check box whether to sign assembly or not and a combo box that locates the file being used for signing. And if you wonder how can you sign the assembly using key container you are out of luck – no option there.
Now you say, no problem, I will sign it the old way using assembly scoped attribute. Actually you still can, but you’ll get a warning (AssemblyKey* attributes are deprecated):

Warning 1 Use command line option ‘/keycontainer’ or appropriate project settings instead of ‘AssemblyKeyName’ E:\Visual Studio 2005\Projects\MyProject\Properties\AssemblyInfo.cs 36 12 MyProject

Hmm. Ok, since I don’t like warnings, I will go passing that /keycontainer parameter through one of Project Properties page. But you can’t. Again, no option there.

Fortunately there is a simple workaround which involves modification of csproj file by hand. You should add this node right under the first <PropertyGroup>node:


(found via this thread).

Happy signing.

Leave a Reply