Aaron Stebner's WebLog

Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio

Prerequisites for running XNA Framework 2.0-based games on Windows

Prerequisites for running XNA Framework 2.0-based games on Windows

  • Comments 2

There are a several prerequisite dependencies that must be satisfied on a Windows system that does not have the XNA Game Studio 2.0 development tools installed in order to be able to play games built on the XNA Framework 2.0.  Most of them are documented in the Distributing Your Finished Game topic in the XNA Game Studio 2.0 documentation, but there is an additional dependency not listed there that is documented in item 1.5.2 in the readme at http://creators.xna.com/gamestudio2/gamestudio2readme.htm.  I wanted to summarize the dependencies that must be installed on a Windows system before you will be able to play games created with XNA Game Studio 2.0 so they can all be found in one place, and also provide some more specific information about how to detect the presence of these prerequisites on a user's system.

In order to play a game created with XNA Game Studio 2.0, a system needs to have the following components installed:

1.  The .NET Framework 2.0

The .NET Framework 2.0 is available as a part of the OS on Windows Vista, and is also available as a redistributable package for pre-Vista operating systems.  Either the original .NET Framework 2.0 release (http://go.microsoft.com/fwlink/?LinkID=76064) or the .NET Framework 2.0 SP1 (http://www.microsoft.com/downloads/details.aspx?FamilyId=79BC3B77-E02C-4AD3-AACF-A7633F706BA5) will work to fulfill this requirement.

The officially documented way to detect the presence of the .NET Framework 2.0 on a system is the following registry value:

[HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v2.0\50727]
Install=1

I have posted some sample code that can be used to implement this type of detection logic in an application setup.

2.  The XNA Framework Redistributable 2.0

The XNA Framework redistributable 2.0 MSI can be downloaded from http://go.microsoft.com/fwlink/?LinkID=78244.

The Distributing Your Finished Game topic describes how to use the MsiQueryProductState API and pass in the value {245F6C7A-0C22-4DE0-8202-2AAA620A1D3A} (which is the XNA Framework redistributable 2.0 MSI product code) to detect the installation state of the XNA Framework redistributable 2.0.  This algorithm requires writing code, and it cannot be implemented using standard Windows Installer actions.  As an alternative, you can add rows to the Windows Installer AppSearch and RegLocator tables to check for the existence of the following registry value to determine whether or not the XNA Framework redistributable 2.0 is installed:

[HKEY_LOCAL_MACHINE\Software\Microsoft\XNA\Framework\v2.0]
NativeLibraryPath

You can use the following WiX v3.0 syntax to set a property named XNAFX20_INSTALLED that can then be checked within an MSI-based setup to determine the XNA Framework redistributable 2.0 install state:

<Property Id="XNAFX20_INSTALLED" Secure="yes">
  <RegistrySearch Id="XnaFx20InstallRegKey"
      Root="HKLM"
      Key="SOFTWARE\Microsoft\XNA\Framework\v2.0"
      Name="NativeLibraryPath"
      Type="raw"
  />
</Property>

3.  The Visual C++ 2005 SP1 redistributable package

The Visual C++ 2005 SP1 redistributable package can be downloaded from http://go.microsoft.com/fwlink/?LinkId=106163.  XNA Framework-based games technically only require the Microsoft_VC80_CRT runtime files (msvcr80.dll), but this redistributable package also includes VC runtime files for ATL, MFC and other VC components.  The .NET Framework 2.0 SP1 includes the necessary Microsoft_VC80_CRT runtime files.  The .NET Framework 2.0 SP1 can be installed as a redistributable package on Windows XP and Windows Server 2003, and it is included in Windows Vista SP1.  However, the only way to install the .NET Framework 2.0 SP1 on the original release of Windows Vista is to install the .NET Framework 3.5.

Visual Studio 2005 SP1 standard and higher editions include merge modules that can be used to include the Visual C++ 2005 SP1 runtime files in an MSI-based setup in order to minimize the setup footprint.  The merge modules are located at %ProgramFiles%\Common Files\Merge Modules on a system that has Visual Studio 2005 installed.  Sample instructions for merging these modules into an MSI-based setup using the WiX toolset can be found in this blog post.

XNA Framework-based games need to include the Microsoft_VC80_CRT merge modules for the appropriate processor architectures (x86, x64 or ia64), and when doing so, you will need to ensure that you are consuming merge modules from a system that has Visual Studio 2005 standard edition or higher and VS 2005 SP1 installed.  If you do not use the SP1 version of these merge modules or redistributable page, you will encounter errors related to side-by-side activation when trying to run your XNA Framework 2.0-based game.

If you use the redistributable package, you can use the information in this blog post to detect whether or not the package is already installed on the system and skip installing it if so.  If you include the merge modules in your MSI, Windows Installer will handle detection and installation of the files for you behind the scenes.

4.  DirectX 9.0c

Technically, only a subset of the DirectX 9.0c runtime redistributable package is needed for XNA Framework-based games (see the list at http://msdn2.microsoft.com/library/bb464156.aspx for specific components that are required).  The DirectX 9.0c redistributable can be installed by using the web installer at http://go.microsoft.com/fwlink/?LinkID=56513.  For scenarios that cannot rely on an active Internet connection during setup, you can download the DirectX SDK and select the necessary redistributable components from the Redist folder that is installed as a part of the SDK.  For more information about redistributing DirectX 9.0c, you can refer to the DirectX Installation for Game Developers article on MSDN.

The general guidance in the DirextX Installation for Game Developers article is to always run DirectX 9.0c runtime setup as opposed to trying to determine whether or not to run it based on a setup-time inventory of the the user's system state.

Additional information

There are several topics on the XNA forums that discuss XNA-based game distribution on Windows.  I encourage you to check them out as well:

  • It sure would be nice if we could get one installer that would determine each systems needs then download and install the required software.  I assume though that the information you have provided here can be used to generate just such an installer.  The issue is the biggest problem when you want someone to try your game and they are not a programmer or otherwise tech savvy.  Multiple installers makes this almost a non-starter in these cases.

  • PingBack from http://felizk.dk/?p=84

Page 1 of 1 (2 items)
Leave a Comment
  • Please add 2 and 1 and type the answer here:
  • Post