Build XNA Game Installer: ClickOnce

This guide assumes:

  • Visual Studio 2010 Professional
  • XNA Game Studio 4.0
  • Users will be Windows

This article is the first of two on how to package your XNA game into an installer for Windows environments. The first is the easier but less customizable option of using Visual Studio’s built in ClickOnce installer. ClickOnce is essentially a hand-holding tool to package up prerequisites, dependencies, manifests, and content. Additionally, it allows you to specify locations from which the users will install the package (CD, Web, Shared Drive). More conveniently, ClickOnce allows you to specify where the application should check for updates in order to automatically update the content when new versions of the application are released. For example, you could specify a URL that the application will use to check for new versions. If a new version is detected, you can specify either the same URL or a different URL to use for downloading the new content.

While ClickOnce is easy to use, it is not perfect for every scenario and can fail quite spectacularly. I have personally run into situations where users could not install updates to the application because of cryptic errors that were only resolved by completely recreating a user account in Windows (I kid you not, this is a Microsoft-sanctioned approach). Many of the errors are difficult to diagnose and the documentation does not help much when it comes to the more advanced features of ClickOnce. It is definitely convenient, but do not use it if you want customization or extendability.

That said, here is how you use ClickOnce to package your XNA game into an installer.

  1. Open your solution in Visual Studio
  2. Right click your main project -> Properties…
  3. Click Publish tab
    • Publishing Folder: local or remote path that will be the destination of the publish (example: C:DevGamesGame1Installer)
    • Installation Folder URL: optional unless you want the users to install from a location different from the publish location
    • Install Mode: Pick offline availability (users should not have to be connected to the internet to play video games!)
    • Click Application Files…
      • Make sure the Publish Status of your game files is set to Include (Auto)
      • Make sure the Publish Status of the XNA libraries is set to Prerequisite (Auto)
    • Click Prerequisites…
      • Microsoft .NET Framework 4 Client Profile
      • Microsoft XNA Framework Redistributable 4.0
      • Windows Installer 3.1
    • Click Updates…
      • Check for updates if you want your application to check for updates through ClickOnce
      • A lot of the options are self explanatory on this screen
    • Click Options…
      • Description tab
        • Publisher name: your company name
        • Suite name: optional used to define a super application that manages this one
        • Product name: the name of your game
      • Deployment tab
        • If you want to deploy to a web page, specify the URL here
        • Check the other options here if need them
      • Manifests
        • Click “Create desktop shortcut” if you want a shortcut
        • Ignore the other options unless you really need them
  4. Specify the version of this publish (you can have it auto increment if you want)
  5. Click either the Publish wizard (which just confirms your already entered information) or Publish Now to begin publish

Your published files will be organized like this:

  • Application Files
    • Contains every version that has been published (in case user needs to rollback to a previous version)
    • Contains “Content” folder which includes files from your Content project in your XNA solution
    • .dll libraries that you created
    • Game icon
    • Game thumbnail
    • ClickOnce application file used to check for updates
    • Game executable
    • Executable manifest
  • ClickOnce application file used to check for updates
  • Setup.exe used to install the game

Note that the Application Files directory will contain a history of every version of your application. If you are not careful when distributing your application, the file size can get huge. Unless you really need every version on each deployment of your application, I recommend you clean this directory up after publishing.

Zip these files up and distribute them to your users. Instruct them to run the Setup.exe file to begin the installation. It will check for any prerequisites that you defined when you setup the ClickOnce project settings. Usually the only thing that needs to be downloaded is the XNA Framework Redistributable. If any errors occur during installation, there is usually a “Details…” button that the user will have to click in order to view the log file. The user usually will have no idea what the errors mean, but they can at least send you the error logs for debugging.

The next article will describe a more customizable approach via Windows Setup Projects.

Leave a Reply

Your email address will not be published. Required fields are marked *