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:
- 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).
- 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.
- 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.
- 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.
- 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.
- 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…



Comments
As you ask around, I’m guessing someone is going to ask you if your setup is a per-user or per-machine install. That is controlled by the ALLUSERS property. I’d guess that most apps are per-machine, meaning that when one user installs it on the computer, all other user accounts on that computer can also use the app. That means that regkeys were created under HKLM (where all users will see them), and shortcuts, files, etc., were all created under the appropriate locations.
Based on that, you will see some ICE warnings/errors come and go. I believe the reason why you had to break the shortcuts out to a 2nd component was it was installing per-user information, while the component was installing per-machine files.
I could go on, but I think the per-user and per-machine will provide you with enough reading & refactoring of your code for now. :)
Thanks mgama. I’ll look into that tonight though you’re likely dead on. I still need shortcuts to go on user specific paths such as the desktop or quick launch (haven’t gotten to the latter yet though). Unless there’s an “all users” version of those two as well. I’ll see what I figure out but I appreciate the info. Thanks!
Ahh, yeah. With the desktop shortcuts, you could create them under “all users” which will show up for all users. But there is no such common location for the quick launch shortcuts AFAIK.
Thanks again. We’ll see how it goes…
Post a comment here