As part of his series about creating a Windows Vista Media Center application, Steven Harding recently posted an item on his blog describing how to create an installer for a Media Center application. In this post, Steven walks through the process of determining what registry entries need to be created under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Media Center\Extensibility, and then adding those registry values to a Visual Studio setup/deployment project.
Charlie Owen posted an item on the Media Center Sandbox blog afterwards that is essentially a response to Steven's blog post. Charlie outlines why the preferred approach for Media Center application developers is to use the RegisterMceApp utility or the RegisterApplication API within setup, and also why the samples in the SDK demonstrate how to use WiX (as opposed to the Visual Studio setup/deployment projects) to create a Media Center application setup.
I've heard questions come up fairly often on the Sandbox forum, comments on my blog and elsewhere regarding deployment options for Media Center applications, and after these 2 posts, I wanted to add a couple of comments of my own on the topic of how to register an application in a setup package so it will appear in the Media Center UI.
Options for registering a Media Center application
First, as seen in these blog posts, there are several options for registering a Media Center application within an MSI-based setup:
- Create the necessary registry values directly as documented in the Writing Registry Keys Directly topic in the Media Center SDK
- Run RegisterMceApp as a custom action during your setup
- Write a custom action DLL that calls RegisterApplication (this is what was shipped in older versions of the Media Center SDK but discontinued in Windows Vista Media Center)
How to register a Media Center application in a Visual Studio setup project
If you are using Visual Studio setup/deployment projects, you will find that they do not support adding custom actions that invoke binaries not installed as part of your product. Therefore, option 2 is out (unless you know how to write scripts that invoke Windows Installer APIs to modify the MSI file after it is built as a post-build step in Visual Studio). Option 3 is fairly complicated and requires fairly in-depth knowledge about Windows Installer to get correct, so that tends to lead people to option 1.
Charlie covered this already, and I also touched on this a while back in this blog post, but I want to reiterate it again here - if you choose to write the registry values directly, you will need to ship separate MSIs for 32-bit OS's and 64-bit OS's or else your installer will not work correctly on 64-bit OS's. Not a ton of people have 64-bit OS's right now, but that number is only going to grow, and people are not happy when they cannot get an application to install and run correctly out of the box on their 64-bit OS.
WiX as an alternative to Visual Studio setup projects
When I first started looking at the steps required to create a Media Center application installer (in a series of blog posts starting with this one a while ago), I wanted to find a solution that would allow me to run RegisterMceApp directly because that file already exists on Media Center systems and it didn't make sense to me to not use it if it is already there. Because I have several years of background in Windows Installer, I naturally gravitated towards WiX as I started investigating options further because it allowed me to use declarative XML to express what I wanted my MSI to do.
There is definitely a learning curve for WiX that does not exist in graphical tools like the Visual Studio setup/deployment projects. However, that learning curve does help you better understand exactly what you are doing to the user's system in your installer, which I think allows you to design and build better installers.
In addition, the learning curve is somewhat mitigated because most Media Center application setups are fairly small and simple (I outlined the actions taken in most of these setups in this blog post). That means that once you have a template that runs the correct custom actions, checks the correct prerequisites, etc, you can fairly easily swap in your payload files and build your own MSI. That is the model I was aiming for with the sample setup files for the Q and Z applications in the Media Center SDK - both of them include fully commented WiX source (WXS) files that explain what each action does to help guide you in the right direction for creating your own setups in WiX.
I recognize now that the Q and Z examples are overly complicated for folks just getting started, which is why I'm glad to see that Charlie has posted some step-by-step instructions to make it easier to get started with this process. I'm also working with him on some ideas to make getting started with WiX for Media Center applications even easier in the future.
Why I use WiX for creating Media Center application setups
Stepping up a level and comparing Visual Studio setup projects and WiX side-by-side for the task of building Media Center application installers, I personally choose to use WiX and when people ask me why, I always mention the following reasons:
- I am able to call RegisterMceApp directly, which keeps me from having to ship separate 32-bit and 64-bit MSIs and is less error prone because I don't have to manually author all of the necessary registry values into my MSI
- In most cases, I can copy and paste the WiX source code from the step-by-step guide, change some variable names and GUIDs, change the names of files being installed and be ready to go very quickly
- I can use VB Express or C# Express for my entire Media Center development project if I want to, whereas the setup projects are only available in VS standard and higher
- I can build everything outside of Visual Studio if I choose to whereas the VS setup projects do not support running via MSBuild
- The MSIs that WiX creates are much cleaner, smaller, and serviceable if I have to release patches; VS inserts a lot of additional information into the MSI that I would prefer to not have and that is not technically required to complete the installation process
- I have better control over what is put into the MSI, whereas VS only exposes a small subset of Windows Installer functionality in the designer UI
I know that WiX isn't for everyone though, but I encourage you to take a look and consider it as an option when building an MSI-based installer for your Media Center application. If you decide to try WiX and run into questions, I have posted a list of useful resources that I often refer to in this blog post.