Any Support for Delay Signed Assemblies?

Topics: User Forum
Apr 13, 2007 at 2:39 AM
The tool does not seem to work with delay signed assemblies. I get the following message: Info: Assembly <assembly> is already signed. Ignored. Is there a special switch, either existing or planned, for delay signing, similar to the SN -R switch?
Apr 20, 2007 at 12:18 AM
Edited Apr 20, 2007 at 12:22 AM
Signer will not work with delay signed assemblies. However, you can still use the Strong Name Tool (Sn.exe) that is part of the Microsoft .NET Framework SDK v2.0. Simply add the following target in your Team Build (TFSBuild.proj) or MSBuild script.

<!-- Sign and verify all compiled assemblies. -->
<Target Name="AfterCompile">
  <!-- Strong Name the assembly. This command assumes it is working with a delay signed assembly. -->
  <Exec WorkingDirectory="$(OutDir)" Command="for %%f in (*.dll;*.exe) do $(SN) -R %%f $(SnkFile)"/>
  <!-- Verify the strong name signing has succeeded and the assembly has a valid strong name. -->
  <Exec WorkingDirectory="$(OutDir)" Command="for %%f in (*.dll;*.exe) do $(SN) -v %%f"/>
The property SN is defined to be the fully qualified path to the Sn.exe executable. By default this would be C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\Sn.exe.

The property SnkFile is the fully qualified path to the Strong Name Key (.snk) file that contains both the private and public keys to complete the signing of the assemblies.

It is a good idea to add the verification step to cause the build to fail if something went wrong in the signing process and the proper error was not raised.