Signing the January 2006 Enterprise Library

If any of you out there use the Patterns & Practices Enterprise Library, you are probably a) Very excited about the changes and the fact that it now runs on v2 of the .Net Framework, b) Very frustrated if you were using a signed version of the previous build.

For those of you out there, I have found and included below the steps required to sign v2 of the Enterprise Library

Enjoy.

I’ve been playing with the strong-naming myself in the last few days, and I understand how painful it is. While I don’t think we’ll be able to automate this process in the installer, I am working on some Visual Studio macros to help with this process – I intend to share this with the community when it’s ready.

In the meantime, here are some steps you can follow to strong-name everything, including the test projects:

  1. Open a VS command prompt and change directory to the place where you want to create your keyfile
  2. Use sn -k keyfile.snk to create a key pair (or reuse an existing keypair that is used in your organization)
  3. Use sn -p keyfile.snk publickey.pk to extract the public key from the keypair
  4. Use sn -tp publickey.pk to display the public key in hex form. Keep the console window open as you’ll need this info later
  5. Open the EnterpriseLibrary.VSTS.sln or EnterpriseLibrary.NUnit.sln solution (depending on which edition of VS is installed)
  6. For each project (including unit tests and design projects):
    a) Double-click on the Properties folder from the Solution Explorer
    b) Go to the “Signing” tab in the properties window, and click the “Sign the assembly” checkbox. Then choose “Browse…” in the dropdown box. Browse to the .snk keypair created earlier
    c) Close the properties window and save changes
  7. In Visual Studio, choose Edit > Find and Replace > Find in Files
  8. Search for InternalsVisibleTo aross the complete solution
  9. For each occurrence of the InternalsVisibleTo attribute:
    a) Copy the full public key (not the token) from the console window that was created with sn -tp.
    b) add the public key to the attribute, for example: [assembly: InternalsVisibleTo("Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Tests, PublicKey=002400000480000094000000060...")]
  10. Save each file you changed
  11. Rebuild the entire solution.