Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 2 (41 posts) 1 2 Next >

Making an installer for your XNA game (Windows)

Last post 2/10/2011 11:07 AM by Kraemer. 40 replies.
  • 3/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 

  • 3/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 ... 

  • 3/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 ...

  • 3/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 

  • 3/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>.

  • 3/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
     

  • 3/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).
  • 4/7/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.
  • 4/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.
  • 4/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.
  • 5/3/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?
  • 7/22/2007 7:18 AM In reply to

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

    This rocks.  Very helpful.  Thanks.
  • 8/29/2007 2:02 AM In reply to

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

    This thread has been tremendously helpful.  Thank you all.

    I'd love to include Game Explorer support and have gone the Inno route. 

    This looks like the way to go:

    http://www.coldacid.net/articles/building-game-explorer-support-your-xna-project

    Before I start fighting, I was wondering if anyone has had success getting Inno to integrate with Game Explorer?

    Even better... Does anyone know of an example of an Inno install script that will do the trick?
  • 8/29/2007 1:28 PM In reply to

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

    Thanks for finding my article useful, YumYumMoose!

    I've been considering modifying DSetup for Inno to add support for Game Explorer. However, I wasn't able to get very far with that, as my primary development machine died a couple months ago and I haven't the money to replace it. (And in the meantime, I've been stuck with an old P2 that barely runs Ubuntu, so I can't get any Windows development done at all.) Since I do non-XNA development as well, DSetup for Inno is bound to have GameUX support eventually, I just need a new computer first.

  • 8/30/2007 9:51 AM In reply to

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

    Thanks FoV.  I've got about a two-week timeframe and am juggling some other things in my life as well now.  I wonder which is the path of least resistance right now: switching to WiX, as it is getting high praise above; or trying to add Game Explorer support to Inno, which I now otherwise have working perfectly with DirectX and XNA dependencies.


  • 9/1/2007 6:22 PM In reply to

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

    Just as a quick follow-up to this: it turns out that it's quite easy to add Game Explorer support to InnoSetup.  Follow the instructions at the link above (http://www.coldacid.net/articles/building-game-explorer-support-your-xna-project ) step-by-step to add Game Explorer support to your XNA Project.  Then, use InnoSetup's support for install and uninstall commands to register and unregister your game.  I will write a blog entry shortly detailing the process... but for now, suffice to say it's very possible, and not very difficult.  Drop me a note if you have any questions.
  • 10/1/2007 8:14 PM In reply to

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

    Thanks so much to the original poster... You saved my game from a very tight deadline.
  • 1/23/2008 2:58 AM In reply to

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

    Just wondering if there is something updated for this.

    I did try to get it to work, and the installer goes as planned, but the program afterwards still doesnt work. I think because the XNA framework is not being installed. I have it mentioned in the script with the new location for the directory (version 2 not 1).

    Has anyone had success with the newer version?
  • 1/29/2008 9:47 AM In reply to

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

    Yeah, I tried it as well and it doesn`t work with XNA 2.0 games. That`s just too bad, because it worked great with XNA Refresh. If anyone has success please post.
  • 1/30/2008 4:06 AM In reply to

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

    OK, it works!!
    Follow this link, and you`ll find out what extra components you need to add to the list of redistributing files in the installer script.   http://forums.xna.com/thread/9924.aspx
  • 2/6/2008 10:26 AM In reply to

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

    You'll need to change your installer script to check for the presence of .NetFramework 2.0 SP1 - after a bit of playing around here's how I changed mine:

    procedure AfterFitbaInstall();
    var ErrorCode: Integer;
    var spval: Cardinal;
    var res: Boolean;
    begin

      res:= true
      if(not  (RegKeyExists(HKLM,'Software\Microsoft\NET Framework Setup\NDP\v2.0.50727')) ) then begin
        res:=false
        end
      else if( not  (RegQueryDWordValue(HKLM,'Software\Microsoft\NET Framework Setup\NDP\v2.0.50727','SP',spval)))  then  begin
        res:=false
        end
      else if( spval<1) then begin
        res:=false
        end;

      if(res=false)then
        begin
          if not ShellExec('open', ExpandConstant('{tmp}\ReDists\dotnetfx3setup.exe'),'', '/noreboot', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
          begin
            // handle failure if necessary
            //Result := false;
            MsgBox('Failed to install .Net Framework 3.0. In order to run the game please ensure you have at least .Net Framework 2.0 SP1 installed', mbInformation, MB_OK);
          end;
        end;
    end;


    Hope that helps. (You might notice I'm using dotnetfx3setup.exe - the .NetFramework 3.0 installer as it's a much smaller addition to the installer than the 2.0 SP1 installer)

    Fritz

    http://www.triplebgames.com

  • 2/6/2008 5:06 PM In reply to

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

    How can the .Net 3.0 redist be SMALLER than the .Net 2.0 SP1 redist? Or is this just some kind of bootsrap installer than fetches everything else over the internet?
  • 2/7/2008 9:54 AM In reply to

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

    Yes it's a bootstrap and requires a further download which isn't ideal but at least it's on Microsoft's bandwidth not mine.

    Fritz



  • 2/7/2008 10:27 AM In reply to

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

    But by choosing the smaller bootstrapper you condemn your users to a longer download and install process.

  • 2/9/2008 5:36 AM In reply to

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

    Yes you do, but for me, the reduction in initial download size (from 47MB->27MB) makes this worthwhile. Also the 2.0 SP1 installer comes in two flavours x86 and x64 whereas the bootstrap will pull down the right version for the users hardware.

    It'd be interesting to see some stats on what percentage of users have the various versions of .Net Framework. If I get time I'll try and build something into the installer that logs how many users require the install, and how many fail to complete it.

    Fritz


    http://www.triplebgames.com
Page 1 of 2 (41 posts) 1 2 Next > Previous Discussion Next Discussion