Description
Deploying an XNA based game requires a lot of patience for writing the installer.
You need to make sure .NET is at least 2.0, to look for the visual 2005 runtimes, to ensure XNA 2.0 framework is also present, and DirectX must be at least 9.0c.
This kind of tests are typically done in the installer. However, depending on what you want to test, and on what you used to build your setup, it can be pretty boring.
So we made a lightweight tool to do this for you. It is particularly adapted to XNA games, but it can also be used for any other. There is a silent mode, so you user won’t even notice a check was performed if he already has all the requisites.
There is a full documentation in the DepChecker package, check it out!
Embedding DepChecker in an installer script
Here below is the NSIS script we used for ArkX. As you can see, we got rid of all the requisites tests.
!define NAME “ArkX”
;——————————–
;Include Modern UI
!include “MUI2.nsh”
!include “InstallOptions.nsh”
;——————————–
;General
;Name and file
Name “${NAME}”
OutFile “ArkX_Setup.exe”
;Default installation folder
InstallDir “$PROGRAMFILES\${NAME}”
;Get installation folder from registry if available
InstallDirRegKey HKCU “Software\${NAME}” “”
;Request application privileges for Windows Vista
RequestExecutionLevel user
;——————————–
;Interface Settings
!define MUI_ABORTWARNING
;——————————–
;Pages
!insertmacro MUI_PAGE_LICENSE “license.rtf”
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;——————————–
;Languages
!insertmacro MUI_LANGUAGE “English”
;——————————–
;Installer Sections
Section “ArkX” MainSec
SectionIn RO
SetOutPath “$INSTDIR”
File “..\bin\ArkX.exe”
File “..\bin\ArkXEdit.exe”
File “..\bin\arkx_params.xml”
File /r “..\bin\Content”
;redist
SetOutPath “$INSTDIR\redist”
File “redist\vcredist_x86.exe”
File “redist\xnafx20_redist.msi”
File “app_deps.ini”
File “DepChecker.exe”
File “crt80tester.dll”
;Store installation folder
WriteRegStr HKCU “Software\${NAME}” “” $INSTDIR
;Create uninstaller
WriteUninstaller “$INSTDIR\Uninstall.exe”
;dependencies
ExecWait “$INSTDIR\redist\DepChecker.exe -q”
SectionEnd
Section “Start Menu Icons” SMSec
;start menu
CreateDirectory “$SMPROGRAMS\${NAME}”
CreateShortCut “$SMPROGRAMS\${NAME}\Play ArkX.lnk” “$INSTDIR\ArkX.exe”
CreateShortCut “$SMPROGRAMS\${NAME}\ArkX Level Editor.lnk” “$INSTDIR\ArkXEdit.exe”
CreateShortCut “$SMPROGRAMS\${NAME}\Uninstall ArkX.lnk” “$INSTDIR\Uninstall.exe”
SectionEnd
;——————————–
;Descriptions
;Language strings
LangString DESC_MainSec ${LANG_ENGLISH} “ArkX and the level editor”
LangString DESC_SMSec ${LANG_ENGLISH} “Create Start Menu Icons”
;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${MainSec} $(DESC_MainSec)
!insertmacro MUI_DESCRIPTION_TEXT ${SMSec} $(DESC_SMSec)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;——————————–
;Uninstaller Section
Section “Uninstall”
;ADD YOUR OWN FILES HERE…
Delete “$INSTDIR\*.*”
RMDir /r “$INSTDIR”
Delete “$SMPROGRAMS\${NAME}\*.*”
RMDir “$SMPROGRAMS\${NAME}”
DeleteRegKey /ifempty HKCU “Software\${NAME}”
SectionEnd