Page 1 of 1

Installing XNA games with INNO Setup

#1 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 956
  • View blog
  • Posts: 6,375
  • Joined: 18-October 08

Posted 05 July 2010 - 03:48 PM

You have worked hard on your XNA game to run under Windows. Now you want to share it with your friends or the world. The problem is you need to install it on people's computer so that it will run properly. You can use the installer that comes with Visual Studio or Visual C# Express. They both work great but don't have the best options when it comes to installing your game. A good alternative is INNO Setup. It is a free program available from Only problem is it is a little hard to generate the script for installing XNA games if you haven't done it before. In this rather short tutorial I will go over a script I made for installing XNA games for Windows.

You will first need to download and install INNO Setup from the above link. You will also need to other files that are the prerequisites for running an XNA game. The first one is the XNA redistributable and the other is the .NET Framework 3.5. The XNA redistributable is the easier of the two, it is installed when you installed XNA. You just need to specify the path were XNA is installed on your computer. The download that will allow you to install the .NET Framework 3.5 can be downloaded from here.

aniri has a good tutorial on working with INNO setup in the Software Development Tutorials on Dream.In.Code. You could add in message boxes that ask if the person running your installer if they want to install the files required to run your game.

With these files you have everything you need to make a complete installer for your XNA game and have it run on a friends computer. What you need now is the script for INNO Setup to create your installer. INNO Setup use a setup similar to an INI file for Windows and Pascal like scripting. The following script is what I used to create the installer for an entry to a game programming challenge. This installer give write access to the directory where I saved preferences for the game.

; Enter infromation about your XNA game here.
#define MyAppName "Last Wave"
#define MyAppVerName "Last Wave v1.0"
#define MyAppExeName "LastWave.exe"

; Enter the location where XNA Game Studio is installed
#define MyGameStudioLocation "C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v3.1"

; Enter the name for the correct version of the XNA Framework MSI
#define XNARedist "xnafx31_redist.msi"

; Enter the location where you have placed the .NET redistributables
#define MyRedistLocation "C:\Users\Jamie\Downloads"

; Download the .NET bootstrapper from the link above
#define DotNetSetup "dotNetFx35setup.exe"

DefaultDirName={pf}\Last Wave
SetupIconFile=C:\Users\Jamie\Documents\Visual Studio 2008\Projects\GC16\GC16\lastwave.ico

Name: english; MessagesFile: compiler:Default.isl

Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked

; NOTE: Don't use "Flags: ignoreversion" on any shared system files
; Files that are prerequistes for your game, .NET framework and XNA Redistributable
Source: {#MyRedistLocation}\{#DotNetSetup}; DestDir: {tmp}; AfterInstall: VerifyDotNet2
Source: {#MyGameStudioLocation}\Redist\XNA FX Redist\{#XNARedist}; DestDir: {tmp}
; Files specific to your game
Source: C:\Users\Jamie\Documents\Visual Studio 2008\Projects\GC16\GC16\bin\x86\Release\LastWave.exe; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\Jamie\Documents\Visual Studio 2008\Projects\GC16\GC16\bin\x86\Release\*; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\Jamie\Documents\Visual Studio 2008\Projects\GC16\GC16\bin\x86\Release\Content\*; DestDir: {app}\Content\; Flags: ignoreversion
Source: C:\Users\Jamie\Documents\Visual Studio 2008\Projects\GC16\GC16\bin\x86\Release\Content\Audio\*; DestDir: {app}\Content\Audio\; Flags: ignoreversion
Source: C:\Users\Jamie\Documents\Visual Studio 2008\Projects\GC16\GC16\bin\x86\Release\Content\Backgrounds\*; DestDir: {app}\Content\Backgrounds\; Flags: ignoreversion
Source: C:\Users\Jamie\Documents\Visual Studio 2008\Projects\GC16\GC16\bin\x86\Release\Content\GUI\*; DestDir: {app}\Content\GUI\; Flags: ignoreversion
Source: C:\Users\Jamie\Documents\Visual Studio 2008\Projects\GC16\GC16\bin\x86\Release\Content\Levels\*; DestDir: {app}\Content\Levels\; Flags: ignoreversion
Source: C:\Users\Jamie\Documents\Visual Studio 2008\Projects\GC16\GC16\bin\x86\Release\Content\Sprites\*; DestDir: {app}\Content\Sprites\; Flags: ignoreversion
Source: C:\Users\Jamie\Documents\Visual Studio 2008\Projects\GC16\GC16\bin\x86\Release\Content\Tiles\*; DestDir: {app}\Content\Tiles\; Flags: ignoreversion
Source: C:\Users\Jamie\Documents\Visual Studio 2008\Projects\GC16\GC16\bin\x86\Release\Content\Data\*; DestDir: {app}\Content\Data\; Flags: ignoreversion; Permissions: users-modify

Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; WorkingDir: {app}
Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Filename: {uninstallexe}
Name: {commondesktop}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Tasks: desktopicon; WorkingDir: {app}

Filename: {tmp}\{#DotNetSetup}; Flags: skipifdoesntexist; Parameters: /q /noreboot
Filename: msiexec.exe; Parameters: "/quiet /i ""{tmp}\{#XNARedist}"""

  hasDotNet :Boolean;

procedure VerifyDotNet();
  hasDotNet := RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5');
    if hasDotNet then

The script may look a little intimidating but it isn't all that hard once you understand its format. To add comments to your installer you start the line with semi-colons, except for the Code section. The reason is the Code section uses Pascal like scripting and the lines end with semi-colons. The script is broken up into sections that are enclosed between [ and ]. Much like in a C or C++ program you can use #define statements that can be expand as constants in your installer. MyAppName is the name of your game. MyAppVerName is the name of your game with the version included. MyAppExeName is the file name of your game's executable. The MyGameStudioLocation is where your version of XNA is installed. If you have the XNA redistributable in a different location you can change the path entered there. XNARedist is the correct name for the XNA redistributable msi. If you used XNA 3.0 you need to use the XNA 3.0 redistributable. MyRedistLocation is the path to where you have the .NET 3.5 redistributable saved. Finally, DotNetSetup is the name of the .NET 3.5 redistributable.

The first section in the INNO Setup script is the Setup section and holds information about your game. AppName is expanded to the MyAppName constant. The next two are expanded as well. DefaultDirName is where you would like your game to be installed by default. In my case it will be installed to the Program Files folder. You can set DefaultGroupName to be the name of the folder your game, and uninstaller, will be installed to in the Start Menu. OutputDir is the directory where your installer will be stored when you compile it using INNO Setup. OutputBasFilename is the base file name your setup will compile to. You can also specify an icon for your setup using SetupIconFile. The next two just use the default values, they say what type of compression to use when you compile your setup script to make an EXE to install from.

The next section, Languages, tells INNO Setup which languages to include in the install that it generates. If you use a language other than English you can modify this section to suit your needs. I would suggest creating a test script using the INNO Setup wizard to see what options are available or look it up in the documentation for INNO Setup.

The Tasks section describes additional tasks that INNO Setup will preform. The one in my script is used to create an icon on the desktop. The way it is setup, INNO Setup will ask if the person installing your game if they want an icon on the desktop.

The Files section holds the files that are to be included in your installer. The first two entries are for the dependencies you need to run an XNA game on a computer. The first one is for the .NET framework and the second is for the XNA redistributable. The AfterInstall part of the .NET framework will run code after the installer that checks to see if the .NET 3.5 Framework is already on the target computer. If it is INNO Setup will skip installing it. The other entries are specific to your game. You specify the full path to your game files, Content directory and any sub-directories in your Content folder. I placed the Data that I wrote to in the Content directory rather than in the directory that I installed the game to. I specified users-modify in the Permissions part so that the end user has access to read, write, and modify files in that directory.

The next section, Icons, details what icons should be installed when your game installs. You will see that two of them have WorkingDir after them. This is so that when you run your game from an icon on the desktop or start menu your game will start in that directory. If you don't then your game will not run.

The Run section are tasks that are run by INNO Setup. The first one will install the .NET Framework if it is not installed on the target computer. The second will install the XNA redistributable.

The last section is the Code section. This section checks to see if the .NET 3.5 Framework is installed on the target computer. To do this it checks for a specific registry key. If it is there it deletes the file for installing the .NET 3.5 Framework so that it won't be installed.

I'm not an expert with INNO Setup. This is just a rather generic script that I've used a few times for installing my games on other people's computers.

Is This A Good Question/Topic? 1
  • +

Replies To: Installing XNA games with INNO Setup

#2 eZACKe  Icon User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Posted 05 July 2010 - 04:12 PM

Excellent tutorial!

I must admit, I was a little intimidated when I scrolled down and saw that script. Though after reading your tutorial I'm fairly confident I could use this as a guide and create my own!

Thanks a lot!

This post has been edited by eZACKe: 05 July 2010 - 04:13 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1