I work on a team whose main focus is the world of software deployment (i.e., installers, WiX, authoring tools, servicing, etc.). I’ve now been on the team for over a year and have decided that’s way too long to not have real hands-on experience with the actual core technology we’re building on such as Windows Installer and WiX. So this weekend, I decided to start making installer packages (aka Setups) for some of the apps I’ve created over time and shared via this blog. I figured that would be a good way to get my feet wet and I’d surely learn a thing or two. 

I chose my most recent tool, Clipboard Snagger, as my first app to setup-ize. I figured it was a good choice as it’s tiny, consists of a single binary, and would just require a few shortcuts and I’d be done. I totally thought this would be a 5-10 minute job as I figured it would be a matter of copy/pasting the “hello world” equivalent of WiX authoring. It turns out it required a few hours for me to get to the point where it seems to be working and I still haven’t really finished (one more shortcut to go–the Quick Launch one).

Though it’s been a bit of a struggle, significantly more than I expected going in, it has actually been a lot of fun to start figuring out how Windows Installer really works (note, I realize I’m barely scratching the surface–baby steps, baby steps). I decided to blog about my journey as I go as it might help others who go through some of the same struggles I’m experiencing now. It also really helps me to write about things I’m learning as it usually forces me to dig a little deeper in my understanding than I would if I was just happily hacking along. Having something remotely technical on my blog once again seems like a good thing too as it’s been a while.

I’ve shared my code in the screenshot above (I was too lazy to figure out how to post it directly as text with line numbers and syntax coloring so a JPEG sounded easy enough). Click here for a full-size version that should be readable.

Anyway, here are some observations (aka things that have me wondering if I’m missing something or not as this looks way more complicated than I expected it to be) and questions I still have to get answers to:

  1. I’ve come to realize (from experience and from others who are way more experienced than I am) that shortcuts in Windows Installer aren’t as simple as I originally assumed. To avoid any ICE errors/warnings (primarily ICE57s) and to get it to build successfully, I had to separate my shortcuts (lines 34-47) from the binary they point to (lines 17-18).
  2. Because of the separation described in #1, I had to create a type 51 custom action (which as far as I can tell is the “assignment operator” of MSI) to have the shortcuts point to the app’s EXE file.
  3.  I’ve seen samples where the RemoveFolder element (line 19) doesn’t seem to be needed but I can’t figure out how to not have it and not get an ICE64 error telling me the ProgMenuGPSoft directory “is in the user profile but is not listed in the RemoveFile table.” I’m pretty sure Windows Installer takes care of automatically uninstalling anything you lay down during install but for some reason I’m having to explicitly remove this directory. It seems to work but I’m pretty sure there’s a way to avoid this.
  4. I think I understand now at to the why but I was surprised (hadn’t really thought it through) to need to write a registry key (lines 27-33) specifically to act as a KeyPath for the two shortcuts.
  5. My MainExePath property (line 52) has me a bit uncomfortable. I don’t really want to give it a default value as it’s designed to be set at install time dynamically but WiX was complaining when I didn’t provide a Value attribute unless I made it “Hidden” which seemed inappopriate. What I currently have feels a little like cheating.
  6. I just now realized in all the refactoring I’ve been doing the RemoveFolder element probably shouldn’t be where it is (if I need it at all). I’m guessing I could have moved it down to the component with the shortcuts as a more natural home but it’s too late for this post as I’ve already created the screenshot and I’m lazy.

I’m going to ask some of the folks I work with some of these questions over the next few days or so but if anyone else stumbles upon this post and has some knowledge to share, please share away in the comments section…