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
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:
- Open a VS command prompt and change directory to the place where you want to create your keyfile
- Use sn -k keyfile.snk to create a key pair (or reuse an existing keypair that is used in your organization)
- Use sn -p keyfile.snk publickey.pk to extract the public key from the keypair
- 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
- Open the EnterpriseLibrary.VSTS.sln or EnterpriseLibrary.NUnit.sln solution (depending on which edition of VS is installed)
- 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
- In Visual Studio, choose Edit > Find and Replace > Find in Files
- Search for InternalsVisibleTo aross the complete solution
- 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...")]
- Save each file you changed
- Rebuild the entire solution.