NAnt: Signing Satelite Assemblies Fix
I’ve been using NAnt to build our source trees at work (via TeamCity ) and came across a somewhat annoying issue when it comes to signing satellite assemblies.
Problem Background
For several of the projects we use the CSLA framework by Rockford Lhotka, the framework doesn’t ship a redistributable binary blob. When it gets built it generates the following:
total 644K
0 .
0 ..
0 /ca-ES
0 /da
0 /de
0 /es
0 /es-ES
0 /fr
0 /hr
0 /it
0 /nl
0 /no
0 /pt
0 /pt-br
0 /ro
0 /ru
0 /sr
0 /sv
0 /zh-CHS
16K Csla.XmlSerializers.dll
156K Csla.dll
4.0K Csla.dll.config
468K Csla.pdb
Inside each of those folders we have the resources for the locale (a Csla.Resources.dll satelite assembly). The NAnt Script uses the KeyFile attribute in the CSC task passing in the CslaKey.snk file to sign the main assembly but it appears the NAnt engine (as of NAnt 0.85) does not pass this key to the Assembly Linker (AL.exe) utility to sign the satelite assembly.
Preliminary Solution
So the easiest way to get around this is to specify in the AssemblyInfo.cs file itself the key file to utilise when signing the assembly. This way the compiler will delegate the key to the child utilties it uses enforcing the key signing process.
[assembly: AssemblyCopyright("Copyright © 2007 Rockford Lhotka")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyKeyFile(@"..\CslaKey.snk")]
// Mark the assembly as CLS compliant
[assembly: System.CLSCompliant(true)]
Hopefully this will be addressed in a future release of NAnt.