XNA Creators Club Online
Page 1 of 2 (34 items) 1 2 Next >
Sort Posts: Previous Next

Making an installer for your XNA game (Windows)

Last post 08-17-2008 8:46 PM by CDarklock. 33 replies.
  • 03-17-2007 7:29 AM

    Making an installer for your XNA game (Windows)

    Hi,

    I've been looking around for info on how to best create an installer for a XNA game on Windows. As I was unable to find anything I decided to see if I could make something that worked on my own. And here is what I've come up with so far :)

     After checking out a couple of install systems I settled on Inno Setup. It's free and uses a high level script language (ObjectPascal). I downloaded the QuickStart Pack from the Inno Setup site (here) and started messing around. This includes ISTool which is kind of an IDE for making Inno Setup scripts. I then used the wizard (File->New) to make the basic installer script.

    After that I added redist files for the DirectX updates and the XNA framework itself (these files are included with GSE). I also made the installer check for .NET 2.0 and if not present download it from Microsoft's site and install it.

    So far I've tested it on a couple of machines with Windows XP and all have worked fine :)

    I do however think that the installer still has some issue:

    • It doesn't check if the base DirectX 9.0c is installed.
    • There should probably be some more info to the user if .NET 2.0 is not found as it is a 22MB download and a somewhat lengthy install.

    Anyway here is the complete Inno Setup script:


    ; Script generated by the Inno Setup Script Wizard.
    ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
    
    #define MyAppName "PjXnaTest"
    #define MyAppVerName "PjXnaTest 0.01"
    #define MyAppPublisher "Prolantic"
    #define MyAppURL "http://www.pellej.com/"
    #define MyAppExeName "WindowsGame1.exe"
    
    [Setup]
    AppName={#MyAppName}
    AppVerName={#MyAppVerName}
    AppPublisher={#MyAppPublisher}
    AppPublisherURL={#MyAppURL}
    AppSupportURL={#MyAppURL}
    AppUpdatesURL={#MyAppURL}
    DefaultDirName={pf}\{#MyAppName}
    DefaultGroupName={#MyAppName}
    OutputBaseFilename=setup_PjXnaTest
    Compression=lzma
    SolidCompression=yes
    
    [Languages]
    Name: english; MessagesFile: compiler:Default.isl
    
    [Tasks]
    Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
    
    [Files]
    Source: C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\Redist\DX Redist\*; DestDir: {tmp}
    Source: C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\Redist\XNA FX Redist\xnafx_redist.msi; DestDir: {tmp}
    Source: bin\x86\Release\WindowsGame1.exe; DestDir: {app}; Flags: ignoreversion
    Source: bin\x86\Release\Content\*; DestDir: {app}\Content; Flags: ignoreversion recursesubdirs createallsubdirs
    ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
    
    [Icons]
    Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}
    Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Filename: {uninstallexe}
    Name: {commondesktop}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Tasks: desktopicon
    
    [Run]
    Filename: {tmp}\dotnetfx.exe; Flags: skipifdoesntexist; Parameters: /Q
    Filename: {tmp}\dxsetup.exe; Parameters: /silent
    Filename: msiexec.exe; Parameters: "/quiet /i ""{tmp}\xnafx_redist.msi"""
    Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#MyAppName}}; Flags: nowait postinstall skipifsilent
    
    [_ISToolDownload]
    Source: http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=0856eacb-4362-4b0d-8edd-aab15c5e04f5&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f5%2f6%2f7%2f567758a3-759e-473e-bf8f-52154438565a%2fdotnetfx.exe; DestDir: {tmp}; DestName: dotnetfx.exe
    
    [Code]
    var
    	hasDotnet2: Boolean;
    
    function InitializeSetup(): Boolean;
    begin
    	hasDotnet2 := RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\policy\v2.0');
    	Result := True;
    end;
    
    // Function generated by ISTool.
    function NextButtonClick(CurPage: Integer): Boolean;
    begin
    	if not hasDotnet2 then
    		Result := istool_download(CurPage)
    	else
    		Result := True;
    end;
    

     

    Any comments/suggestions appreciated,

     -Pelle 

  • 03-17-2007 8:20 AM In reply to

    Re: Making an installer for your XNA game (Windows)

    Finally found the 'enhanced editor' option in my profile settings ;)

    I'll try to explain the different sections of the script.

    ; Script generated by the Inno Setup Script Wizard.
    ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

    #define MyAppName "PjXnaTest"
    #define MyAppVerName "PjXnaTest 0.01"
    #define MyAppPublisher "Prolantic"
    #define MyAppURL "http://www.pellej.com/"
    #define MyAppExeName "WindowsGame1.exe"

    [Setup]
    AppName={#MyAppName}
    AppVerName={#MyAppVerName}
    AppPublisher={#MyAppPublisher}
    AppPublisherURL={#MyAppURL}
    AppSupportURL={#MyAppURL}
    AppUpdatesURL={#MyAppURL}
    DefaultDirName={pf}\{#MyAppName}
    DefaultGroupName={#MyAppName}
    OutputBaseFilename=setup_PjXnaTest
    Compression=lzma
    SolidCompression=yes

    [Languages]
    Name: english; MessagesFile: compiler:Default.isl

    This was all generated by the wizard and contains basic info about the app, like name, version, executable, website etc.

     

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

    This allows the user to create a desktop icon for the game. I believe the actual icon is taken from the exe file. 

     

    [Files]
    Source: C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\Redist\DX Redist\*; DestDir: {tmp}
    Source: C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\Redist\XNA FX Redist\xnafx_redist.msi; DestDir: {tmp}
    Source: bin\x86\Release\WindowsGame1.exe; DestDir: {app}; Flags: ignoreversion
    Source: bin\x86\Release\Content\*; DestDir: {app}\Content; Flags: ignoreversion recursesubdirs createallsubdirs
    ; NOTE: Don't use "Flags: ignoreversion" on any shared system files

    The Files sections list all files to be included in the installer. The first 2 lines lists the redistributables for DirectX and XNA - note that their destination is set to {tmp}, i.e. they will be extracted to a temp folder during installation. Next comes the files for the game itself: the executable and the binary content files. I've used relative paths here - the install script is located at the my project folder, i.e. where the csproj file is stored.

    TO BE CONTINUED ... 

  • 03-17-2007 8:48 AM In reply to

    Re: Making an installer for your XNA game (Windows)

    ... CONTINUED

    Been fighting the forum editor a bit ;) Please NOTE that it wraps some of the code lines, so use the version of the script form the first post if you copy/paste it.

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

    The various icons to install in the start menu and on the desktop.

     

    [Run]
    Filename: {tmp}\dotnetfx.exe; Flags: skipifdoesntexist; Parameters: /Q
    Filename: {tmp}\dxsetup.exe; Parameters: /silent
    Filename: msiexec.exe; Parameters: "/quiet /i ""{tmp}\xnafx_redist.msi"""
    Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#MyAppName}}; Flags: nowait postinstall skipifsilent

    List the things to run during install. First is the .NET 2.0 installer, it is skipped if it doesn't exist, i.e. if it hasn't been downloaded. Next is the DirectX and XNA redists and finally the game itself if the user chose to run it after install.

     

    [_ISToolDownload]
    Source: http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=0856eacb-4362-4b0d-8edd-aab15c5e04f5&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f5%2f6%2f7%2f567758a3-759e-473e-bf8f-52154438565a%2fdotnetfx.exe; DestDir: {tmp}; DestName: dotnetfx.exe

    This is the files to be downloaded. Here is only the .NET 2.0 installer (with a really long URL .. yuk). 

    ONE MORE PART COMMING ...

  • 03-17-2007 8:53 AM In reply to

    Re: Making an installer for your XNA game (Windows)

    ... CONTINUED

    [Code]
    var
        hasDotnet2: Boolean;

    function InitializeSetup(): Boolean;
    begin
        hasDotnet2 := RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\policy\v2.0');
        Result := True;
    end;

    // Function generated by ISTool.
    function NextButtonClick(CurPage: Integer): Boolean;
    begin
        if not hasDotnet2 then
            Result := istool_download(CurPage)
        else
            Result := True;
    end;

    This is the part with the ObjectPascal code. There is a function that checks in the registry if .NET 2.0 is installed. The second function was originally generated by the wizard, but I then added a check so it only downloads if .NET 2.0 is not found.

    Well that's it,

     -Pelle 

  • 03-24-2007 6:30 AM In reply to

    Re: Making an installer for your XNA game (Windows)

    Hey Pelle, I wrote an extension for Inno some time ago to hook in DSetup. I was more recently planning to add support for Game Explorer to it, but it's a bit of a pain to work with, and besides these days I work pretty much exclusively with WiX for installer packages.

     You can find my extension at <http://www.coldacid.net/project/isxdx>.

    Christopher S. 'coldacid' Charabaruk
  • 03-26-2007 4:23 AM In reply to

    Re: Making an installer for your XNA game (Windows)

    Hi FoV,

    Thanks for the info. I did have a quick look at WiX, but thought it looked more complicated to use than InnoSetup. Maybe I should give it another chance :)

     -Pelle
     

  • 03-27-2007 9:19 AM In reply to

    Re: Making an installer for your XNA game (Windows)

    If you want to integrate with Game Explorer, I'd suggest WiX regardless of whether a game uses the XNA Framework or not. I've used Inno for quite some time but I've lately found that preparing WI packages with WiX is a lot less annoying, although it is more work. Still, it's not too much more complicated; most of the extra work for me has simply been making sure that every file that should be installed is mentioned in the WiX files -- as far as I know you can't simply wildcard files into the package as you can with Inno (but then again I could be wrong).
    Christopher S. 'coldacid' Charabaruk
  • 04-07-2007 4:29 AM In reply to

    Re: Making an installer for your XNA game (Windows)

    Just wanted to say a quick thanks for posting this, it's saved me a lot of time and hassle. Very much appreciated Pelle.
  • 04-10-2007 4:14 PM In reply to

    Re: Making an installer for your XNA game (Windows)

    This is GREAT Pelle! Thank you so much for allowing us all to benefit from your research into this. I went from nothing to a functioning installer for my first game in about 10 minutes.
    Xbox MVP 2006 & 2007
  • 04-13-2007 1:47 AM In reply to

    Re: Making an installer for your XNA game (Windows)

    I second the recommendation for WiX.  It's perfect, whether it's for enterprise apps or simple games.
  • 05-03-2007 11:42 AM In reply to

    Re: Making an installer for your XNA game (Windows)

    Question: Will this work with xp x64 or vista 64, cause i noticed in the .net 2.0(i think it was(it was one of the re-dists)) that there was an x64 folder instead of x86, will your code work with 64 bit stuff?
    _____________________________________________________
    There are 10 types of people in this world... Those who know binary, and those who do not.
  • 07-22-2007 7:18 AM In reply to

    Re: Making an installer for your XNA game (Windows)

    This rocks.  Very helpful.  Thanks.
    Muzz http://www.PositronicArts.com/blog
  • 08-29-2007 2:02 AM In reply to