How to Start
After extracting the release you downloaded, you'll end up with an example installer that installs a dummy game and a start menu shortcut. Open the provided solution in SharpDevelop 3.0 to get started customizing your installer.
To make it compile, you'll first need to replace some GUIDs. Each installer needs to have its own unique product id, update id as well as an id for each of the installable components. To make sure those lazy XNA developers don't forget to change those
GUIDs, I replaced them with unworkable strings ;-)
- Search & Replace "!replace-this-with-real-product_guid" with a random GUID
- Search & Replace "!replace-this-with-real-upgrade_guid" with a random GUID
- Search & Replace "!replace-this-with-game-component_id" with a random GUID
- Search & Replace "!replace-this-with-menu-component_id" with a random GUID
(Google for "GUID Generator" if you don't have one handy.)
Set up Requirements
The next step is to tell the installer about your requirements. The file Config.wxi contains all the settings you can make. You will find detailed descriptions next to each configuration option, but I'll provide a short overview here as well
Change Company and Product Name
- InstallPrerequisitesIfRequired - Controls whether the XNA Framework and DirectX Runtime will be installed if it's missing on the target system. Disabling it reduces the installer size, but the installer will not let the user continue if they don't
have gotten XNA from somewhere else already
- RequiredShaderModel - The shader model your game requires. The installer checks this (using an ancient version of the DirectX 9 interface any OS since Windows XP SP2 has built-in) and warns the user if his hardware doesn't fulfill the requirements.
- RequiredDotNetProfile - Whether you require .NET 4.0 or .NET 4.0 Client Profile (set to "Full" or "Client"). All XNA 4.0 projects by default target the .NET 4.0 Client Profile. The advantage of the .NET 4.0 Client Profile is that it's
marginally smaller than the a full install of .NET 4.0. If the user already has a full install of .NET 4.0, he is able to run applications targeting the .NET 4.0 Client Profile, too, of course.
By default, the game installs "MyCompany MyGame", an exciting dexterity game where you have to click the "OK" button of a message box with your mouse. Of course ,not everyone wants his game to be called "MyGame", so here's
how to change this:
In Setup.wxs, you can change the name, manufacturer, package description and comments to match your own product name.
You can also rename the SharpDevelop solution and project so you can see right away which game's installer you're working on when SharpDevelop is open.
Finally, you need to tell the installer which files it should place on the target system. This is where some intimate contact with the details of WiX and Windows Installer technology becomes unavoidable.
Open Files.wxs and you will find a bunch of <Directory /> and <Component /> nodes. Those are currently set up to install a file named "Game.exe" and create a shortcut for it in the start menu.
In the simplest case, you can just go ahead and put as many <File /> nodes besides the one for Game.exe as you need and all is well. Maybe rename Game.exe and give the start menu shortcut a better name while you're at it.
It becomes more difficult if you want to create subdirectories in your game directory. To do this, please follow this guide:
In short, you need to put another <Directory /> element beneath the <Directory /> element for 'INSTALLDIR'. Then you have to add another <Component /> element with a new unique GUID to put your <File /> elements under. This <Component
/> then has to be added to a <Feature /> in Setup.wxs.
A <Feature /> is something you can either install of leave out, eg. your installer might have the features "Game", "Editor" and "Docs". Any number of <Component /> elements can be linked to a feature, causing the files
and registry entries in that <Component /> to be installed when the feature is selected. Multiple features can link the same <Component /> (eg. you might have a component "shared files") and it will only be installed once.
Yes, it's complicated, but on the upside, you have complete control over any changes the installer does, you'll get support for uninstalls automatically and it's all free :)