edg3
12-09-2008, 02:12 PM
This will guide you through the process of creating an installer for your XNA game that will allow you to distribute it to people that do not have the runtimes installed as the installer will install the necesary things for your games to run id they arent already there.
Many thanks to Dan Marshall: A judge for the RetroRemakes competition
Source: http://www.zombie-cow.com/forum/index.php?topic=326.0
Links in here: ]
Nuclex Installer - 27mb~ (http://www.nuclex.org/nuclex-installer-2.0-beta.zip)
Sharp Develop 3 - 17mb~ (http://sharpdevelop.net/OpenSource/SD/Download/GetFile.aspx?What=Setup&Release=Montferrer)
Quoted so you can read it on this forum.
I figured I should probably put this somewhere. It might come in handy for Large Scale Vehicular Stealing??
It's sort of a free-association stream of consciousness, the steps I remember following to get the damned thing working. This installer checks to see if the user has the necessary components to run and XNA game, and if they don't, installs them. It then installs the game proper. It adds something like 28mb to the filesize, so it might be an idea to offer two versions - an installer that installs the necessary kit, and a separate one that then installs game files, to cut down on unnecessary bandwith useage.
The Nuclex installer is a dream. Get it here ? it checks if the End User has the three XNA components necessary, and if not, offers to install them, then installs your game. Sadly, it?s not the most user-friendly experience, so I thought I?d type up a step-by-step walkthrough of what I did to get my game working.
First thing you need to do is download the installer?s files. You?re going to need to edit them so you can tack your game onto the installer, so download a program called SharpDevelop. It?s a compiler, and reads all the files nicely.
Unpack Nuclex, and boot up SharpDevelop.
Go to File-> Open-> Project/ Solution and open the MyGame project in the Nuclex folder.
There are only really two files you need to concern yourself with: Files.wxs and Setup.wxs, they?re in the Sources folder, to the left. Double click ?Sources?, and then open them both up.
You need to work your way through both files (don?t worry, they?re short) finding the bit that says ?!replace-with-real-[whatever]-GUID?. Your GUID number is generated in your game project?s AssemblyInfo.cs file ? open your project as usual and hunt down that file, and copy the long string of digits to the clipboard.
Head back to SharpDevelop, and replace any instances of !replace-with-GUID with your string, keeping it inside the double quotes. There are four of them ?in total, but if you miss one, just hit F8 to rebuild and you?ll get an error message that you can double-click to take you right to it.
Once those are filled in press F8 and MyGame.msi will be created in /bin/Debug. If you double-click it, an installer will come up that detects and offers to install all the necessary components to get your game working. If you follow through with the install, a folder called MyGame will be created in Program Files with a file called License in it.
You?ll notice at this point that every step throughout setup is labelled as generic stuff like MyGame and MyCompany, which is the next thing that needs changing.
First, look up to the top right of Sharp Develop to where it says ?Solution MyGame?. Right click it, and go to Rename. Call it whatever you want your installer to be called ? presumably the name of your game. Likewise, you need to change the MyGame just under that as well.
Look at Files.wxs, there?s a ?YourApp? and ?Your Application? that need changing.
This is where we need to talk about the ?Name? part of that line. Anything defined as a Name MUST be 8 characters or less. You need to define one, but chances are it?ll never be used, so it can pretty much be whatever you want. You should probably make it something sensible so you don?t run into trouble later on when you?ve got two files named ?s.png? or what-have-you. Just remember that Name is 8 characters or less.
Looking back at Files.wxs, you can leave MyComponent as is.
Next, boot up Setup.wxs, and set about changing all the generic MyGame and what-have-you in there, too. There?s only two sections to fill in ? if you look at the comments you?ll see it says ?you do not need to modify anything below this point?, so stop there.
The other thing to do is expand the Documents folder, find License.rtf and open it. There?s a section towards the top that says ?Your License goes here?. For the sake of making everything look nice and professional, change that to something suitable.
So we?ve got an installer! And everything?s set up to suggest we?re going to install your XNA game, which is great. You?ll notice that we haven?t actually added any of your game?s files to the project yet, though, so if you hit F8 to compile, you?ll still just have an installer that installs the three XNA components.
Next, we?re going to add your game files, which is a bit of a pain.
Right click on the icon UNDER what was Solution MyGame that you renamed, and go to Add-> Existing Item. Find the files that go in the root directoy of you installed game?s folder. That?s the .exe, etc etc. Add the files, and click ?Copy? on the little box that comes up.
You?ll probably have files in folders as well, and those also need adding. Again right click in the same place as before, but add a folder and rename it to something suitable (presumably what it is in your game?s Release build folder). Then Right click it again, and Add files from that folder that make up your game. Again, Copy rather than Link, and work your way through until all your game?s files are in the SharpDevelop Solution.
Then boot up Files.wxs
If you look between the <Component> </Component> tags, you?ll see the License <File>.
Copy and paste that line directly underneath, and change accordingly so you?ve got something that looks like this:
<Component Id="MyComponent" Guid="22d6cab0-eb38-4a56-ad1b-0076ec5643e0" DiskId="1">
<File Id="LicenseFile" Name="license.rtf" Source="$(sys.SOURCEFILEDIR)/../Documents/license.rtf"/>
<File Id="GTAExe" Name="GTA.exe" LongName="Grand Theft Auto.exe" Source="$(sys.SOURCEFILEDIR)/../GTA.exe"/>
Let?s go back to those Name and LongName components. If your file is eight characters or less, great ? you don?t need a LongName component. Just fill in the Name=?thisbit.exe? with whatever your file is called (extension and all) and don?t add a LongName element too. You can, but you?ll get a warning that doing so is redundant and pointless.
If your file has a long name, it?ll need a LongName element. As discussed, you can put pretty much whatever you like in Name (in the example above, I?ve abbreviated ?Grand Theft Auto.exe? to ?GTA.exe?). It doesn?t really matter, because you?re only going to be able to use the LongName when your file is unpackaged at the other end. So add a LongName=?this bit here.exe? for any files that have a name over 8 characters.
What that line of code is going to do is pick up on the .exe you just copied into the Solution, pop it into the installer, and unpack it into ProgramFiles/YourGame when someone runs your .msi installer. Perfect! Continue that process of putting <File blah blah blah /> between the component tags until all the files that go into ProgramFiles/YourGame are mentioned in Files.wxs.
The next problem is that we?ve got files in folders, and the directory structure needs to be preserved on install. We need to tell the installer to put any files that are in /audio in a /audio folder on your End User?s PC.
If you look at the structure of Files.wxs, it?s set out as follows:
<DirectoryRef>
<Directory> - Program Files
<Directory> - Your game name folder
</Directory> - End of Your Game Name Folder
</Directory> - end of Program Files
<DirectoryRef> - end of Directory Ref
Underneath </Component> you need to add the following:
<Directory Id="Audio" Name="audio">
<Component Id="AudComponent" Guid="22d6cab0-eb38-4a56-ad1b-0076ec5643e0" DiskId="1">
<File Id="GTAaudioxgs" Name="GTAaud.xgs" LongName="Grand Theft Auto.xgs" Source="$(sys.SOURCEFILEDIR)/../audio/GTAaud.xgs"/>
</Component>
</Directory>
Although obviously with your GUID. That?ll install that file into /audio. Add all your Audio files, and make more Directories and Components as necessary, giving them sensible ID and Name tags as you go, until all your game?s files are mentioned in the Files.wxs. Notice how the path to the file at the end corresponds to the folder we added to the project ? that line?s telling the installer where to find your file, so if it?s in a /BumFluff folder, make sure you add it in there.
Check the directory structure?s right -
<Directory Id="ProgramFilesFolder" Name="PFiles">
... refers to Program Files, and is closed with a </Directory> towards the end of the file (the one before </DirectoryRef>).
Anything between those tags goes into Program Files. Anything inbetween your custom Directory tags will go into the appropriate folder.
Next, you need to bring up Setup.wxs again, and add the following code just above that green comment that says ?You do not need to modify anything below this point?:
<Feature Id="RequiredFiles" Title="Required Files" Level="1">
<ComponentRef Id="AudComponent" />
<ComponentRef Id="FontComponent" />
<ComponentRef Id="MediaComponent" />
</Feature>
You need to change those ComponentRef Id tags to whatever you labelled them in Files.wxs
Excitingly, that?s it. If you?ve typed everything in correctly, hit F8 and your .msi will be compiled. If it can?t find a file, check the spelling and the path.
TroubleShooting:
The other file you might like to peek at is Config.wxs. There are three parameters here that tell the installer how to behave. InstallPrerequisitesIfRequired should be 1, really. Otherwise your installer will unhelpfully just point out to the End User that they don?t have the necessary files, before refusing to continue.
If you want the one-click install setup (which I assume you do if you?re jumping through all these hoops), make sure that?s set to 1.
RequiredShaderModel lets you specify what shader model your End User?s graphics card is capable of. If you know your game is using 2.0 shaders for example, put that in.
IntegratedBuild should be set to 0.
The only other thing worth mentioning is make sure you?ve downloaded a relevant copy of the Nuclex Installer ? my first efforts were thwarted when I realised the installer would only offer up XNA 1.0 refresh to my End User, and my game was made in XNA 2.0. So double check that download.
Hope that?s of some help.
Many thanks to Dan Marshall: A judge for the RetroRemakes competition
Source: http://www.zombie-cow.com/forum/index.php?topic=326.0
Links in here: ]
Nuclex Installer - 27mb~ (http://www.nuclex.org/nuclex-installer-2.0-beta.zip)
Sharp Develop 3 - 17mb~ (http://sharpdevelop.net/OpenSource/SD/Download/GetFile.aspx?What=Setup&Release=Montferrer)
Quoted so you can read it on this forum.
I figured I should probably put this somewhere. It might come in handy for Large Scale Vehicular Stealing??
It's sort of a free-association stream of consciousness, the steps I remember following to get the damned thing working. This installer checks to see if the user has the necessary components to run and XNA game, and if they don't, installs them. It then installs the game proper. It adds something like 28mb to the filesize, so it might be an idea to offer two versions - an installer that installs the necessary kit, and a separate one that then installs game files, to cut down on unnecessary bandwith useage.
The Nuclex installer is a dream. Get it here ? it checks if the End User has the three XNA components necessary, and if not, offers to install them, then installs your game. Sadly, it?s not the most user-friendly experience, so I thought I?d type up a step-by-step walkthrough of what I did to get my game working.
First thing you need to do is download the installer?s files. You?re going to need to edit them so you can tack your game onto the installer, so download a program called SharpDevelop. It?s a compiler, and reads all the files nicely.
Unpack Nuclex, and boot up SharpDevelop.
Go to File-> Open-> Project/ Solution and open the MyGame project in the Nuclex folder.
There are only really two files you need to concern yourself with: Files.wxs and Setup.wxs, they?re in the Sources folder, to the left. Double click ?Sources?, and then open them both up.
You need to work your way through both files (don?t worry, they?re short) finding the bit that says ?!replace-with-real-[whatever]-GUID?. Your GUID number is generated in your game project?s AssemblyInfo.cs file ? open your project as usual and hunt down that file, and copy the long string of digits to the clipboard.
Head back to SharpDevelop, and replace any instances of !replace-with-GUID with your string, keeping it inside the double quotes. There are four of them ?in total, but if you miss one, just hit F8 to rebuild and you?ll get an error message that you can double-click to take you right to it.
Once those are filled in press F8 and MyGame.msi will be created in /bin/Debug. If you double-click it, an installer will come up that detects and offers to install all the necessary components to get your game working. If you follow through with the install, a folder called MyGame will be created in Program Files with a file called License in it.
You?ll notice at this point that every step throughout setup is labelled as generic stuff like MyGame and MyCompany, which is the next thing that needs changing.
First, look up to the top right of Sharp Develop to where it says ?Solution MyGame?. Right click it, and go to Rename. Call it whatever you want your installer to be called ? presumably the name of your game. Likewise, you need to change the MyGame just under that as well.
Look at Files.wxs, there?s a ?YourApp? and ?Your Application? that need changing.
This is where we need to talk about the ?Name? part of that line. Anything defined as a Name MUST be 8 characters or less. You need to define one, but chances are it?ll never be used, so it can pretty much be whatever you want. You should probably make it something sensible so you don?t run into trouble later on when you?ve got two files named ?s.png? or what-have-you. Just remember that Name is 8 characters or less.
Looking back at Files.wxs, you can leave MyComponent as is.
Next, boot up Setup.wxs, and set about changing all the generic MyGame and what-have-you in there, too. There?s only two sections to fill in ? if you look at the comments you?ll see it says ?you do not need to modify anything below this point?, so stop there.
The other thing to do is expand the Documents folder, find License.rtf and open it. There?s a section towards the top that says ?Your License goes here?. For the sake of making everything look nice and professional, change that to something suitable.
So we?ve got an installer! And everything?s set up to suggest we?re going to install your XNA game, which is great. You?ll notice that we haven?t actually added any of your game?s files to the project yet, though, so if you hit F8 to compile, you?ll still just have an installer that installs the three XNA components.
Next, we?re going to add your game files, which is a bit of a pain.
Right click on the icon UNDER what was Solution MyGame that you renamed, and go to Add-> Existing Item. Find the files that go in the root directoy of you installed game?s folder. That?s the .exe, etc etc. Add the files, and click ?Copy? on the little box that comes up.
You?ll probably have files in folders as well, and those also need adding. Again right click in the same place as before, but add a folder and rename it to something suitable (presumably what it is in your game?s Release build folder). Then Right click it again, and Add files from that folder that make up your game. Again, Copy rather than Link, and work your way through until all your game?s files are in the SharpDevelop Solution.
Then boot up Files.wxs
If you look between the <Component> </Component> tags, you?ll see the License <File>.
Copy and paste that line directly underneath, and change accordingly so you?ve got something that looks like this:
<Component Id="MyComponent" Guid="22d6cab0-eb38-4a56-ad1b-0076ec5643e0" DiskId="1">
<File Id="LicenseFile" Name="license.rtf" Source="$(sys.SOURCEFILEDIR)/../Documents/license.rtf"/>
<File Id="GTAExe" Name="GTA.exe" LongName="Grand Theft Auto.exe" Source="$(sys.SOURCEFILEDIR)/../GTA.exe"/>
Let?s go back to those Name and LongName components. If your file is eight characters or less, great ? you don?t need a LongName component. Just fill in the Name=?thisbit.exe? with whatever your file is called (extension and all) and don?t add a LongName element too. You can, but you?ll get a warning that doing so is redundant and pointless.
If your file has a long name, it?ll need a LongName element. As discussed, you can put pretty much whatever you like in Name (in the example above, I?ve abbreviated ?Grand Theft Auto.exe? to ?GTA.exe?). It doesn?t really matter, because you?re only going to be able to use the LongName when your file is unpackaged at the other end. So add a LongName=?this bit here.exe? for any files that have a name over 8 characters.
What that line of code is going to do is pick up on the .exe you just copied into the Solution, pop it into the installer, and unpack it into ProgramFiles/YourGame when someone runs your .msi installer. Perfect! Continue that process of putting <File blah blah blah /> between the component tags until all the files that go into ProgramFiles/YourGame are mentioned in Files.wxs.
The next problem is that we?ve got files in folders, and the directory structure needs to be preserved on install. We need to tell the installer to put any files that are in /audio in a /audio folder on your End User?s PC.
If you look at the structure of Files.wxs, it?s set out as follows:
<DirectoryRef>
<Directory> - Program Files
<Directory> - Your game name folder
</Directory> - End of Your Game Name Folder
</Directory> - end of Program Files
<DirectoryRef> - end of Directory Ref
Underneath </Component> you need to add the following:
<Directory Id="Audio" Name="audio">
<Component Id="AudComponent" Guid="22d6cab0-eb38-4a56-ad1b-0076ec5643e0" DiskId="1">
<File Id="GTAaudioxgs" Name="GTAaud.xgs" LongName="Grand Theft Auto.xgs" Source="$(sys.SOURCEFILEDIR)/../audio/GTAaud.xgs"/>
</Component>
</Directory>
Although obviously with your GUID. That?ll install that file into /audio. Add all your Audio files, and make more Directories and Components as necessary, giving them sensible ID and Name tags as you go, until all your game?s files are mentioned in the Files.wxs. Notice how the path to the file at the end corresponds to the folder we added to the project ? that line?s telling the installer where to find your file, so if it?s in a /BumFluff folder, make sure you add it in there.
Check the directory structure?s right -
<Directory Id="ProgramFilesFolder" Name="PFiles">
... refers to Program Files, and is closed with a </Directory> towards the end of the file (the one before </DirectoryRef>).
Anything between those tags goes into Program Files. Anything inbetween your custom Directory tags will go into the appropriate folder.
Next, you need to bring up Setup.wxs again, and add the following code just above that green comment that says ?You do not need to modify anything below this point?:
<Feature Id="RequiredFiles" Title="Required Files" Level="1">
<ComponentRef Id="AudComponent" />
<ComponentRef Id="FontComponent" />
<ComponentRef Id="MediaComponent" />
</Feature>
You need to change those ComponentRef Id tags to whatever you labelled them in Files.wxs
Excitingly, that?s it. If you?ve typed everything in correctly, hit F8 and your .msi will be compiled. If it can?t find a file, check the spelling and the path.
TroubleShooting:
The other file you might like to peek at is Config.wxs. There are three parameters here that tell the installer how to behave. InstallPrerequisitesIfRequired should be 1, really. Otherwise your installer will unhelpfully just point out to the End User that they don?t have the necessary files, before refusing to continue.
If you want the one-click install setup (which I assume you do if you?re jumping through all these hoops), make sure that?s set to 1.
RequiredShaderModel lets you specify what shader model your End User?s graphics card is capable of. If you know your game is using 2.0 shaders for example, put that in.
IntegratedBuild should be set to 0.
The only other thing worth mentioning is make sure you?ve downloaded a relevant copy of the Nuclex Installer ? my first efforts were thwarted when I realised the installer would only offer up XNA 1.0 refresh to my End User, and my game was made in XNA 2.0. So double check that download.
Hope that?s of some help.