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

Making an installer for your XNA game (Windows)

Last post 10/20/2008 9:10 AM by XNA Guy. 34 replies.
  • 2/10/2008 9:16 PM In reply to

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

    Some things I found out while making an installer with XNA 2.0, taking in consideration everything Fritz added :

    - The dotnetfx3setup.exe (.NET 3.0 Installer bootstrap) does NOT include .NET 2.0 SP1, so is worthless in the case of XNA 2.0. And the 3.0 SP1 download doesn't work for [_ISToolDownload], I get a 404 error everytime. So I ended up using the x86 2.0 SP1 installer, which works with ISToolDownload and assume the amount of x64/IA64 machines is a very small propotion that is well able of reading a FAQ. Perhaps the .NET 3.5 includes it, I haven't tested because I thought it was getting a bit invasive to install every framework up to 3.5 just to have the bloody service pack...

    - Using the script Fritz suggested with :
     if not ShellExec('open', ExpandConstant('{tmp}\ReDists\dotnetfx3setup.exe'),'', '/noreboot', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then


    ...made it run into an infinite loop on some machines, where the installer would report that it's already installed and try again, and loop. I suspect this happens on machines that have 3.0 but not 2.0 SP1.

    So my suggestion (and final choice) is the following script :
    // All the stuff above the Run directive is yours to choose

    [Run]
    Filename: {tmp}\NetFx20SP1_x86.exe; Flags: skipifdoesntexist; Parameters: /q
    Filename: {tmp}\dxwebsetup.exe; Parameters: /Q
    Filename: msiexec.exe; Parameters: "/quiet /i ""{tmp}\xnafx20_redist.msi"""
    // Add your game executable after that

    [_ISToolDownload]
    Source: http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=79bc3b77-e02c-4ad3-aacf-a7633f706ba5&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f0%2f8%2fc%2f08c19fa4-4c4f-4ffb-9d6c-150906578c9e%2fNetFx20SP1_x86.exe; DestDir: {tmp}; DestName: NetFx20SP1_x86.exe; Tasks: ; Languages:

    [Code]
    var hasDotNet2SP1: Boolean;

    function InitializeSetup(): Boolean;
    var spval: Cardinal;
    begin
      hasDotNet2SP1 := True
      if (not(RegKeyExists(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v2.0.50727'))) then
      begin
        hasDotNet2SP1 := False
      end
      else if (not(RegQueryDWordValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v2.0.50727', 'SP', spval))) then
      begin
        hasDotNet2SP1 := False
      end
      else if (spval < 1) then
      begin
        hasDotNet2SP1 := False
      end;

    Result := True;
    end;

    function NextButtonClick(CurPage: Integer): Boolean;
    begin
    if not hasDotNet2SP1 then
    Result := istool_download(CurPage)
    else
    Result := True;
    end;

    Hope this helps!
  • 4/27/2008 6:59 PM In reply to

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

    The Inno installer works very well for me, but this thread has not mentioned its one major weakness: there is no check for pixel shader 1.1 support. 

    Is there a simple way to add this functionality?

  • 4/28/2008 10:22 AM In reply to

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

    There is nothing simple you can use.

    The easiest way is to jsut code the check into the start of your game.

    To get the installer to check you would have to wait untill you at least know that native Direct is installed and then you could call out to a native program you wrote to check for pixel shader level. There's no way to o it before DX is installed. If you wait tiwll after XNA framework is installed you can use a XNA based checker though you would also have to write that yourself.

    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
  • 4/28/2008 3:10 PM In reply to

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

    How do you code the shader check into the game if the target computer fails to launch the game owing to the unsupported graphics card?

    I think if the XNA graphicsadapter cannot be called, then the game will hang at launch.

    Or something obvious that I am missing, as I am quite new to programming? 

  • 4/28/2008 3:33 PM In reply to

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

    THe game will launch just fine - the requirements for starting up an XNA game are just .Net 2.0

    However when the device gets created it will throw an excpetion you can catch and gracefully terminate.

    Or you can check the graphics card caps and see if it has all the features you need - there is an example here http://msdn2.microsoft.com/en-us/library/bb975668.aspx

    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
  • 8/17/2008 12:31 AM In reply to

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

    PelleAtor:
    Anyway here is the complete Inno Setup script:

    After a bunch of questions about installers, I've made some modifications to the script to support XNA 2.0 and handle the VC redist files.

    ; Script generated by the Inno Setup Script Wizard.  
    ; (Then extensively modified by Caliban Darklock.)  
    ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!  
     
    ; Enter the name of your game here
    #define MyAppName "Railgun"  
     
    ; Enter the name of your game and a version number here
    #define MyAppVerName "Railgun (Alpha) 0.1"  
     
    ; Enter the name of your company, or just your name
    #define MyAppPublisher "Darklock Communications"  
     
    ; Enter the URL of your website
    #define MyAppURL "http://www.darklock.com/xna/"  
     
    ; Enter the path to your game project - check Visual Studio properties for the path
    #define MyAppLocation "C:\Documents and Settings\Caliban\My Documents\Visual Studio 2005\Projects\RailgunAlpha\RailgunAlpha"  
     
    ; Enter the name of your game executable
    #define MyAppExeName "RailgunAlpha.exe"  
     
    ; Enter the location where XNA Game Studio is installed
    #define MyGameStudioLocation "C:\Program Files\Microsoft XNA\XNA Game Studio\v2.0"  
     
    ; Enter the name for the correct version of the XNA Framework MSI
    #define XNARedist "xnafx20_redist.msi"  
     
    ; Enter the location where you have placed the VC and .NET redistributables
    #define MyRedistLocation "C:\Documents and Settings\Caliban\My Documents\xnareqs"  
     
    ; search microsoft.com for "visual c++ sp1 redistributable" to get the VC redist  
    ; enter the name of the executable file here
    #define VCRedist "vcredist_x86.exe"  
     
    ; Download latest .NET from http://www.microsoft.com/net/ (download button on menu)  
    ; enter the name of the executable file here
    #define DotNetSetup "DotNetFX35Setup.exe"  
     
    ; Once you've filled in all the variables above and downloaded your redist packages,  
    ; everything under this point should JUST WORK for most XNA projects.  
     
    [Setup]  
    AppName={#MyAppName}  
    AppVerName={#MyAppVerName}  
    AppPublisher={#MyAppPublisher}  
    AppPublisherURL={#MyAppURL}  
    AppSupportURL={#MyAppURL}  
    AppUpdatesURL={#MyAppURL}  
    DefaultDirName={pf}\{#MyAppName}  
    DefaultGroupName={#MyAppName}  
    OutputBaseFilename={#MyAppName}Setup  
    Compression=lzma  
    SolidCompression=yes  
     
    [Languages]  
    Name: english; MessagesFile: compiler:Default.isl  
     
    [Tasks]  
    Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked 
     
    [Files]  
    ; DirectX and XNA Framework redistributables  
    Source: {#MyGameStudioLocation}\Redist\DX Redist\*; DestDir: {tmp}  
    Source: {#MyGameStudioLocation}\Redist\XNA FX Redist\{#XNARedist}; DestDir: {tmp}  
     
    ; .NET and VC redistributables - VerifyDotNet2 MUST run BEFORE VerifyDotNet2sp1!  
    Source: {#MyRedistLocation}\{#DotNetSetup}; DestDir: {tmp}; AfterInstall: VerifyDotNet2  
    Source: {#MyRedistLocation}\{#VCRedist}; DestDir: {tmp}; AfterInstall: VerifyDotNet2sp1  
     
    ; The game itself  
    Source: {#MyAppLocation}\bin\x86\Release\{#MyAppExeName}; DestDir: {app}; Flags: ignoreversion  
    Source: {#MyAppLocation}\bin\x86\Release\Content\*; DestDir: {app}\Content; Flags: ignoreversion recursesubdirs createallsubdirs  
     
    [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}\{#DotNetSetup}; Flags: skipifdoesntexist; Parameters: "/q /noreboot" 
    Filename: {tmp}\{#VCRedist}; Flags: skipifdoesntexist; Parameters: "/q" 
    Filename: {tmp}\dxsetup.exe; Parameters: /silent  
    Filename: msiexec.exe; Parameters: "/quiet /i ""{tmp}\{#XNARedist}""" 
    Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#MyAppName}}; Flags: nowait postinstall skipifsilent  
     
    ; The code section doesn't like comments for some reason.  
    ; VerifyDotNet2 removes the .NET setup if you already have .NET 2.0 installed.  
    ; VerifyDotNet2sp1 removes the VC redist if you already have .NET 2.0 SP1, -or-  
    if you don't have .NET 2.0 at all (it will be installed along with .NET 3.5).  

    ; Using the skipifdoesntexist flag allows the setup to ignore the missing files.  

    ; The editor here on the forums doesn't like the title of this section to be "Code".
    ; I've changed it to "CODESECTION". Change it back to "Code" before you compile.
    [CODESECTION]  
    var  
      hasDotNet2 :Boolean;  
      hasDotNet2sp1 :Boolean;  
     
    procedure VerifyDotNet2();  
    begin  
      hasDotNet2 := RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\policy\v2.0');  
        if hasDotNet2 then  
          DeleteFile(ExpandConstant('{tmp}\{#DotNetSetup}'));  
    end;  
     
    procedure VerifyDotNet2sp1();  
    begin  
      hasDotNet2sp1 := RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\v2.0 SP1');  
        if hasDotNet2sp1 or not hasDotNet2 then  
          DeleteFile(ExpandConstant('{tmp}\{#VCRedist}'));  
    end; 

    This version has a bunch of parameters up top, which - once you've set them for your project - pretty much do everything. I've added comments to explain what all the constants are, and if you just fill in the blanks it should "just work".

  • 8/17/2008 7:31 PM In reply to

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

    One thing I noticed while skimming through the script posted above - the logic you're using to detect the .NET Framework 2.0 and 2.0 SP1 are not the officially documented detection registry values.  I'd suggest using the registry values in the sample code that I posted on my blog because those are using the officially documented and supported detection methods for these products.  There are links in the comments in the sample code to the documentation on MSDN for .NET Framework deployment as well.

    Thanks!

  • 8/17/2008 7:58 PM In reply to

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

    Aaron Stebner:
    the logic you're using to detect the .NET Framework 2.0 and 2.0 SP1 are not the officially documented detection registry values

    It's a hack. Inno Setup is very badly documented, and it took me an immense amount of time to get something together that did even this half-arsed job of dependency checking. Updating it to use official procedures is on my radar.

    EDIT: Since I was thinking of it, and Aaron has kindly saved me the trouble of looking up the officially supported mechanisms on my own, I've redone the code section to use the proper methods.

    var  
      hasDotNet2 :Boolean;  
      hasDotNet2sp :Cardinal;  
     
    procedure VerifyDotNet2();  
    begin  
      hasDotNet2 := RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727');  
        if hasDotNet2 then  
          DeleteFile(ExpandConstant('{tmp}\{#DotNetSetup}'));  
    end;  
     
    procedure VerifyDotNet2sp1();  
    begin  
      RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727', 'SP', hasDotNet2sp);  
      if (hasDotNet2sp > 0) or not hasDotNet2 then  
          DeleteFile(ExpandConstant('{tmp}\{#VCRedist}'));  
    end; 

    The new version of the setup script can be downloaded in its entirety at my XNA blog, or directly via http://www.darklock.com/xna/innosetup_xna.zip 

  • 8/17/2008 8:46 PM In reply to

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

    Added fix.

    var  
      hasDotNet2 :Boolean;  
      hasDotNet2sp :Boolean;  
      whichDotNet2sp :Cardinal;  
     
    procedure VerifyDotNet2();  
    begin  
      hasDotNet2 := RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727');  
        if hasDotNet2 then  
          DeleteFile(ExpandConstant('{tmp}\{#DotNetSetup}'));  
    end;  
     
    procedure VerifyDotNet2sp1();  
    begin  
      hasDotNet2sp := RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727', 'SP', whichDotNet2sp);  
      if (hasDotNet2sp and (whichDotNet2sp > 0)) or not hasDotNet2 then  
          DeleteFile(ExpandConstant('{tmp}\{#VCRedist}'));  
    end; 

    During my tests on Virtual PC machines (VPC rules, thanks MS!), I reasoned that when a machine does not have .NET 2.0, the Cardinal containing the service pack number might just have garbage in it if the RegQueryDWordValue() call fails. This new version validates that the call succeeeded.

  • 10/20/2008 9:10 AM In reply to

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

    I found it better to do this which gives the user status messages of what's going on while the silent installs happen

    Filename: {tmp}\{#DotNetSetup}; Flags: skipifdoesntexist; Parameters: "/q /noreboot"; StatusMsg: "Installing .NET..." 
    Filename: {tmp}\{#VCRedist}; Flags: skipifdoesntexist; Parameters: "/q"; StatusMsg: "Installing VC Redist..." 
    Filename: {tmp}\dxsetup.exe; Parameters: /silent; StatusMsg: "Installing DirectX..." 
    Filename: msiexec.exe; Parameters: "/quiet /i ""{tmp}\{#XNARedist}"""; StatusMsg: "Installing XNA Game Studio..." 
    Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#MyAppName}}; Flags: nowait postinstall skipifsilent  
     
Page 2 of 2 (35 items) < Previous 1 2 Previous Next