I finally have version 1 of my Smugmug gallery plug-in completed. The next step is to do the installer. To get a plug-in up on the Windows Live Gallery, it must have an installer that meets the requirements on the Gallery Developer Center page. A content plug-in has to meet these requirements:
- Content Plugins must be built using either the .NET 1.1 or .NET 2.0 frameworks.
- Content Plugins must be packaged and submitted as a Microsoft Installer (*.msi).
- If you use the .NET 2.0 framework, the installer must link to the .NET 2.0 download site or use the Visual Studio 2005 Bootstrapper. The Bootstrapper detects and downloads the correct .NET 2.0 framework.
- Your installer must copy the assembly to the “Plug -ins” sub-directory of the Windows Live Writer installation directory.
I have #1, my plug-in uses the .NET 2.0 framework. Number 2 is that it must be packaged using a Windows Installer .msi setup. I’m still figuring out the best way how to implement #3, but I’m not sweating it. With #4, I’m not doing it that way. The alternative method is to install the plug-in in your own folder and write a registry key to Software\Windows Live Writer\PluginAssemblies (HKLM or HKCU) with the name of your plugin and the path to it. That way you don’t have to worry about where Live Writer was installed to. In fact that page is probably obsolete, there is an MSDN article that covers the registry method.
Let’s start with the .msi requirement.
I looked that the “Setup Project” template in VS 2008. Um, no thanks. After 30 minutes of playing with it, I started getting annoyed. It felt awkward and non-intuitive. Granted, most things with Windows Installer are awkward and non-intuitive, but I couldn’t get fast handle on “Setup Project” template. It was easy enough to get the files installed, but getting the registry written correctly was a task I just couldn’t figure out. After two years of doing .msi with Wise For Windows and now InstallAware, I have a pretty good idea of an .msi is supposed to work.
I decided to knock out an setup with InstallAware. It took about 5 minutes and worked perfectly. But it was 1.2 MB in size. That seemed excessive to deploy 45K for two assemblies. Frankly any installer will be excessive, but I have to follow requirement #2. I have lots of love for InstallAware and it’s my tool of choice for application installs, but it still bothers me to have a setup that 26 times larger than the files being deployed.
With VS’s “Setup Project” and InstallAware out of the picture, I decided to check out WiX. WiX stands for WIndows Installer XML and is an open source toolkit for building .msi setups from an XML source file. The current version, 3, installs nicely into VS 2008. It installed so nicely, I didn’t need to be concerned with how to run the Candle (the WiX compiler) or Light (the WiX linker). There is also a .msi decompiler, named Dark. It will emit Wix source code from a .MSI or .MSM file.
WiX source code is pretty intimidating when you first look at it. if you have no experience with authoring Windows Installer, it will be hard to grasp at first. The WiX site has a nice tutorial, but it’s for version 2 and uses syntax that’s deprecated in version 3. Fortunately, I was able to google the differences and I was able to get a working installer in about an hour. It’s not handling step 3 completely, but it is terminating the install if .NET 2.0 is not available.
The size of the .msi is much smaller, about 220k. Still way too large, but it’s as about as small as I’m going to get for a .msi file. So far, I’m very impressed with WiX. Once you start getting the hang of the syntax, it’s very clear on how to setup a proper .msi file. There’s even a open source editor called WixEdit. I didn’t need it for this task, but I think I make take at peek at it at another timer.
Enough people are using it so that I was able to google for the bits I needed. Morten Lyhr had a great post on how to detect the .NET Framework. I figured out how to write the registry key from a post by Chris Jackson. Bonnie (one of the Live Writer developers) had a good sample WiX file for installing a plug-in. While I didn’t follow her pattern, it did give me a tour of the neighborhood. Mike Stall has a good post that covers the basics. I think I need to spend some time reading the blogs of the WiX developers, they have a build a really cool tool.