Geeks With Blogs

News View Michael Stephenson's profile on BizTalk Blog Doc View Michael Stephenson's profile on LinkedIn
Michael Stephenson keeping your feet on premise while your heads in the cloud

I have recently been having discussions with some of the guys from our Ops Team about the GAC and BizTalk. One of the things they had observed was that when we upgraded some of our BizTalk applications using the technique where you are able to drain the system and fully remove then replace the application the uninstallation and reinstallation process left the assemblies from the previous version in the GAC.

I explained the relationship between the management database in BizTalk and the storage of assemblies in the GAC and how assemblies in the GAC are considered shared so it is not safe in most cases to just uninstall them without some consideration over how they may be used elsewhere on the box. This is also the default behaviour of msi's which are generated by the BizTalk management console.

In our case we could be fairly sure that assemblies from old versions of our applications which are still in the GAC would not be used elsewhere I started to think about how we could clean this up in a low risk way.

I also didn't really want to get into the position of adding pre and post installation scripts to the msi at this stage as they were working well and I wanted to minimize changes.

After thinking about this for a while I've come up with the following tool:

BizTalk GAC Cleaner

The tool does the following:

  1. Gets a list of all of the assemblies in BizTalk's management database

This uses the registry to get the management database for the database the server you run the tool on is connected to

2. Gets a list of all of the assemblies in the GAC

3. Compares the lists to find assemblies which can be removed from the GAC

The comparison looks for assemblies which are in both the GAC and Management database based on the assembly name and public key token. It then looks for versions of these assemblies which are in the GAC but not in the management database and then considers these assemblies to be ones which can be removed.

4. Produces a script which you can review and then run on your server to do the uninstallation   

Although I'm not a huge fan of doing this as it's not really an issue, I'm sure the odd person will have to this at some point so I've popped the source code on the below link if anyone wants it.

The sample includes versions of this for BizTalk 2006 R2. It should also work on BizTalk 2009. I used it on 2010 Beta but had to recompile it against .net 4.0 and I updated the ExplorerOM reference.



Make sure you review and test your script before you run it anywhere !!!!!

And don't blame me if your referencing your assemblies from other places on the same box as I said above review the script and test it :-)



Thanks to the below posts for the code samples for interacting with the GAC

Posted on Friday, June 18, 2010 6:40 PM BizTalk , BizTalk Build & Deployment | Back to top

Comments on this post: BizTalk GAC Cleaning Utility

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Michael Stephenson | Powered by: