You may need to re-sign a strongly named assembly, for example after using an AOP (Aspect Oriented Programming) build step involving PostSharp or AfterThought.
If like me, you are not using TFS or MSBUILD to build, then there are at least 2 ways:
a) run sn.exe from a script, and write the password to stdin
see here for a C# example.
note: with the .NET4 version of sn.exe it seems to be impossible to execute it as external process (at least on Windows XP), and write the password to stdin (I tried with python + with C#, and sn.exe seems to just exit without waiting for password input).
b) use sn.exe to re-sign the password, using a pfx that has already been installed.
If you have already installed the pfx file, then you might know the container name (usually Visual Studio uses a name like VS_KEY_ABAB1234ABAB1234)
If, like me, you do not know or remember the container name, then just re-install the pfx file:
sn -i myPfxFile VS_KEY_ABAB1234ABAB1234
sn.exe will prompt you for a password, as it installs the certificate in the pfx file.
You can then make sn.exe re-sign your assembly, without any prompt for password:
sn -Rca myAssembly.dll myVSkey
The above can be used in a build script, as no interaction is required :-)
NB remember to check that the signing actually works:
sn -v myAssembly.dll
Comments
Post a Comment