Sunday, February 03, 2008

Using Wix for my Live Writer Plug-in

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:

  1. Content Plugins must be built using either the .NET 1.1 or .NET 2.0 frameworks.
  2. Content Plugins must be packaged and submitted as a Microsoft Installer (*.msi).
  3. 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.
  4. 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.


  1. Hi Chris,

    I've been working with installers for the past 5 years, using both Installshield and Wise. For the past week I've tried using WIX. Initially I really liked it. I felt that it would be easier for developers to use this tool over Wise, Installshield or VS. Small applications were fine, but once I started creating large apps with complex installs, the wxs file became hard to manage. I haven't fully ruled it out and maybe I need to rethink the way I create installers. All in all its free!

  2. Hi Johhny,

    Personally, I only use Wix for small projects. For larger projects, it takes less time for me to create an installer using InstallAware. For larger projects, the 7zip compression used by InstallAware usually generates smaller installers than Wise or InstallShield

    I dropped Wise For Windows after playing with InstallAware for a few days. They abstract out the process for building an installer, they have script like language that compiles down to Windows Installer technology. The few years that I spent with Wise were helpfule because their project files are much closer to the format of a .msi database, it does give you a better understanding of what's under the hood. That being said, I'll still never use Wise again.

    Compared to Wise, it's much easier to installers than can upgrade over previous versions. You don't have to manually update any codes, each build can upgrade over previous builds.

    Wise was much buggier and their support was awful. I can't imagine how bad it is now that Symantec owns Wise, but I doubt it got any better.

  3. Great post - and thanks for all the links. Just getting started with Wix - also for a Live Witer Plug-in, and your review set me on the right path.


Note: Only a member of this blog may post a comment.