UnleashIt is a great product developed by Matt Hawley of Excentrics World. It enables single click deployment of asp.net projects over several transports, including file copy, FTP server, and zip file. Matt's done a lot of work to make the app look very clean and intuitive, while at the same time offering powerful advanced options. In his latest release, Matt opened the project up to third party plugins. I spent some time earlier this week building one, and figured I'd take a few moments to document my experience.
I work on one particular project where we have to publish a release build of an ASP.Net web site to a Server 2003 machine using Interdev and front page server extensions. The site is huge - it has hundreds of pages and thousands of lines of code-behind logic. It has a number of PDF and flash files which are very large in size. It's currently takes up about 100 megs of storage, and it grows by the day.
We only publish out the site content and compiled binaries - no source code, resx files, debugging information or the like. UnleashIt is powerful, but as of yet doesn't support Front Page deployment. I figured that the best way to avoid having to drop the entire site into Interdev every time I wanted to push out a release was to take advantage of the logic that is already built into UnleashIt that determines which files need to be published. I'd build a plugin that copies those files that UnleashIt published to a second folder, which I refer to as a shadow folder. With this solution, I can simply drop the contents of the shadow folder into Interdev to update the new files.
Included with the UnleashIt install is a plugin information document. This document is fairly thorough, and I'll try not to reproduce too much of the documentation here. I'd suggest reading it through (it's only 3 pages) before starting on your own plugin.
The first thing I did was create a new solution (I'm using VS.Net 2003) and add a class library project to it, which I named ShadowIt. I then made references to the required dlls (UnleashIt.Common.dll and UnleashIt.Extensibility.dll). I also added a reference to the Skybound Visual Styles component, which Matt uses in his UI. For reference, I added the UnleashIt.Plugins project to the solution. This project is located at C:\Program Files\Unleash It\Plugins\SourceCode\UnleashIt.Plugins. I'm a bit lazy, so I borrowed code from this project on more than one occasion for tasks like persisting settings and implementing the configuration screen. I also used it as a template when trying to decide on my file system and namespace structure.
To allow your plugin to work with UnleashIt, you simple need to implement Matt's extensive IDeployment interface. This allows you to set up custom properties for your plugin, and lets you hook into events that occur during deployment. Some of the basic properties that I had to supply values for were Name, ID, and Description. These allow UnleashIt to identify the plugin and present it to the users of UnleashIt. Hooking events is optional - for ShadowIt, I decided to hook three events.
The first event that I hooked was ShowConfiguration. If you return true from the HasConfiguration property of the IDeployment interface, this method will be called by UnleashIt. It lets you launch a windows form to gather parameters for your plugin. I built a small UI that gathers information on where the files should be shadowed. There's not much to that part - just keep in mind that if you store configuration information specific to a particular profile, you'll need to store them in such a way that you can use UnleashIt.Common.Profile data to pull it out later (I stored my configuration information against ProfileName). I used the factory pattern and abstract base classes in my implementation - have a look at the attached source code if you'd like to see how this works.
The next event in the chain of execution that I hooked into was PreDeploy. This fires right before UnleashIt is about to sling the new versions of your files to the destination directory. I used it as an opportunity to verify that the user has configured the application for this profile. If the plugin is activated for a profile, but no shadow folder has been specified, the user is notified at this point that the plugin won't do anything until they specify one.
The event that does the actual work is PostDeploy. At this point, UnleashIt gives you access to a collection of FileCopyInfo objects that represent files that have been successfully deployed. I used the Path property of the FileCopyInfo class to do my shadow work. The Path property has the full path to the deployed file, including the file name. I simply replaced the part of the Path which represents the ShadowIt destination (found by querying Profile.LastUsedDestinationDirectory) with my own shadow folder path.
In order to test by plugin, I changed the ShadowIt project properties to build to the Plugins folder (C:\Program Files\Unleash It\Plugins). After building under the Debug profile, I launched UnleashIt and attached to the UnleashIt-GUI.exe process. I could then set breakpoints in my code and configure and deploy until I had tested all of the features of the plugin. The ability to debug in source code while your component is running in a foreign process is really, really cool.
With my next plugin, which I plan to build next week, I plan to write unit tests before starting my build. When starting on ShadowIt, I was so eager to jump into the plugin building process and look at the data structures that UnleashIt provided as parameters in it's interface methods that I skipped this essential step.
I welcome any feedback on the source code, which you can download from here.
Update 11.23.2004: Uploaded new code base. Added menus, about, and readme forms, and changed from StringDictionary to NameValueCollection for internal settings storage.

posted on Wednesday, November 17, 2004 2:35 PM