Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio
All postings are provided AS IS with no warranties, and confer no rights. Additionally, views expressed herein are my own and not those of my employer, Microsoft.
Windows XP Media Center Edition supports two types of add-ins - hosted HTML applications and Media Center add-ins (also known as background add-ins). I will cover hosted HTML applications separately. I will focus on creating setup packages for Media Center add-ins in this article.
I have created an example setup package for a Media Center add-in using WiX that I will describe in more detail in the rest of this article. You can find a downloadable example of the WiX source file for a Media Center add-in setup that I will use in the rest of this article at this location. I tried to create this example using what appear to be the steps that would be needed for a "typical" Media Center add-in, so hopefully this will be useful for most add-ins that you might need to create setup packages for.
Payload contained in an add-in setup package
A Media Center add-in is a managed code assembly that can call Media Center extensibility APIs to interact with and control Media Center. There are a few types of files that comprise a background add-in:
Actions performed in an add-in setup package
The setup for the example Media Center add-in that I have created consists of the following activities:
More details about the design of an add-in setup package
There are a few important design considerations that have been applied while creating this example setup package for a Media Center add-in.
1. Media Center add-in assemblies should be installed to the GAC
The Media Center SDK states that add-in assemblies must be installed in the global assembly cache (GAC) or to %windir%\ehome (the local directory where Media Center files are installed to) in order for Media Center to be able to load them. As a best practice, add-ins should be installed to the GAC as opposed to %windir%\ehome. This is accomplished in the sample add-in by adding the attribute Assembly=".net" to the File element that represents the add-in assembly:
<File Id="myaddin.dll" Name="myaddin.dll" KeyPath="yes" src="myaddin.dll" Checksum="yes" Vital="yes" Assembly=".net" />
2. The way that RegisterMceApp.exe is run is important
As I previously described in this blog post, RegisterMceApp.exe will return non-zero values (which indicate failure to Windows Installer) if an application that is already unregistered is unregistered again or if an application that is already registered is registered again. Because of this, the example setup package runs RegisterMceApp.exe /u and ignores the return code and then runs RegisterMceApp.exe in installation mode and checks the return code during initial installation and repair. During uninstall, it runs RegisterMceApp.exe /u and ignores the return code.
3. An add-in setup package should check for its prerequisites
An add-in should check and make sure that the OS it is installed on is a valid Media Center OS and that it is running the version of Media Center that the add-in is designed for. The Media Center SDK does not document any official ways of detecting Media Center OS versions, so I chose to use the registry-based method that Media Center hotfixes use for the example add-in. The following registry key/value can be used to identify Media Center version:
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Media Center]Ident = REG_SZ
The example add-in package checks that the OS is in the Windows XP family by validating that VERSIONNT = 501 and also checks for Media Center 2005 with Update Rollup 2.
The example add-in setup package also validates that the file %windir%\ehome\RegisterMceApp.exe exists on the system at the beginning of setup because it is needed later in the setup process.
Finally, the add-in setup package has a launch condition that checks for administrative rights by using the Privileged property and blocks setup from running if the user running setup does not have administrative rights.
Using the example to create other add-in setup packages
You can use the following steps to create an MSI-based setup package for your Media Center add-in using my example as a template:
1. Download the latest build of version 2.0 of the WiX toolset and save it to your local hard drive
2. Download the example WiX source file for a Media Center add-in that I posted and save it to your local hard drive
3. Update the WiX source file as appropriate for your add-in:
4. Compile your add-in MSI using the following command lines and WiX tools:
Note: the files candle.exe, light.exe, WixUI.wixlib and WixUI_en-us.wxl are all included in the WiX toolset. The toolset also includes a help file (named wix.chm) that you can use as a reference if you want to create more advanced MSI packages using the above example and information as a basis.
Looks like the sample code for this gone now :(
Hi Ryan - Sorry for the hassle here. It looks like my file server is down for maintenance again.
The sample included in this blog post is essentially the same and the one shipped in the Media Center SDK for the Q and Z sample applications. I used the sample described in this blog post as a basis for the WiX authoring for Q and Z.
In the meantime, I'd suggest that you download and install the Media Center SDK from http://www.microsoft.com/downloads/details.aspx?FamilyId=A43EA0B7-B85F-4612-AA08-3BF128C5873E&displaylang=en, and then look at the sample setup for the Q application. It is located at %ProgramFiles%\Microsoft SDKs\Windows Media Center\v5.0\Samples\Windows Media Center Presentation Layer Samples\Q\Setup (if you installed the SDK to the default location).
Hopefully this helps....
I haven't been keeping up with the Media Center Sandbox forums as well as I would like to lately, and
As part of his series about creating a Windows Vista Media Center application, Steven Harding recently