Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio
All postings are provided AS IS with no warranties, and confer no rights. Additionally, views expressed herein are my own and not those of my employer, Microsoft.
Important note: The information in this blog post is specific to the XNA Game Studio 3.0 beta. There have been some changes in the final release of XNA Game Studio 3.0. For more information about Windows game publishing using the final release of XNA Game Studio 3.0, please refer to the updated blog post at http://blogs.msdn.com/astebner/archive/2008/10/31/9027445.aspx.
As previously noted, the XNA Game Studio 3.0 beta has been released. One of the features that we added in the beta is ClickOnce publishing support for XNA Framework-based Windows games. I wanted to go over the behind-the-scenes details for this feature and explain how to configure and use it in a Windows game.
What is ClickOnce and why hasn't it worked in the past for games?
ClickOnce is an application deployment technology that can be used to publish applications to Web servers or network file shares for simplified installation scenarios. ClickOnce features have been available in Visual Studio for a couple of versions, but have not worked well with XNA Game Studio for a couple of reasons:
Changes made in the XNA Game Studio 3.0 beta for ClickOnce scenarios
We have addressed the above issues in the XNA Game Studio 3.0 beta by doing the following:
How to publish an XNA Game Studio 3.0 Windows game
There are a couple of ways to access publishing functionality in Visual C# 2008 Express Edition or Visual Studio 2008. The following steps will allow you to publish using the default settings for prerequisite packages:
ClickOnce publishing output
The above steps will produce a publishing output folder that contains the following:
The above steps will automatically configure your game to include the .NET Framework 3.5 and the XNA Framework Redistributable 3.0 as prerequisites. It will use the default deployment settings for each of these prerequisites. For the .NET Framework 3.5, this means that setup.exe will detect whether or not the user's system needs the .NET Framework 3.5 and will download and install it if it is missing. For the XNA Framework Redistributable 3.0, it will deliver the MSI as payload in a sub-folder next to setup.exe (in the beta only).
In the XNA Game Studio 3.0 beta, you will notice that publishing a Windows game will result in a warning in the error list that states the following:
No 'HomeSite' attribute has been provided for 'Microsoft XNA Framework Redistributable 3.0', so the package will be published to the same location as the bootstrapper.
We did not specify a HomeSite value in the beta because we did not post the XNA Framework Redistributable 3.0 MSI as a separate download. In the final release of XNA Game Studio 3.0, we will post the XNA Framework Redistributable 3.0 MSI as a separate download, and we will update this bootstrapper package to specify a valid HomeSite value. That will cause the default publishing behavior to be to cause setup.exe to detect whether or not the user's system needs the XNA Framework Redistributable 3.0 and to download and install it if it is missing (like the default behavior for the .NET Framework 3.5).
How to configure non-default ClickOnce publishing options
In order to change the default publishing behavior for XNA Game Studio 3.0 Windows game, you can use the following steps:
Notes about installing Windows games using ClickOnce
After publishing your game, you can install it on another system by running setup.exe or by running <game>.application (if the target system already has the .NET Framework 2.0 or higher, it will know how to handle the .application file extension). Any missing prerequisites will be installed, and then your game will be deployed. Here are a few key notes about this deployment process:
Using a setup/deployment project to create a game installer
Visual Studio Professional Edition and higher offers the ability to create MSI-based installers in addition to ClickOnce packages. Both of these deployment solutions use the same bootstrapper packages for installing prerequisites. This means you can also use a setup/deployment project in Visual Studio 2008 Professional Edition and higher to create an MSI to install your game, and then include the XNA Framework Redistributable 3.0 as a prerequisite.
It is important to note that XNA Game Studio 3.0 does not support automatically adding game or content project output to the setup project (which is normally done by right-clicking the setup project, choosing Add | Project output... and selecting the primary output of the desired project in the Add Project Output Group dialog). As a result, you will have to manually add the binary files and content files that you want to install as a part of your game to your setup project one-by-one if you choose this option.
Here are steps that you can use to accomplish this:
After a build, your setup project's output directory will contain the following:
In the XNA Game Studio 3.0 beta, you will see the same warning about the HomeSite attribute as described above in the ClickOnce publishing steps. This is because the same underlying bootstrapper package is used by ClickOnce and setup/deployment projects. In the final release of XNA Game Studio 3.0, it will be possible to enable download-and-install-on-demand scenarios for the XNA Framework Redistributable 3.0.
Important note about the contents of the XNA Framework Redistributable 3.0
The above information describes how to create an installer for an XNA Framework-based Windows game. There are a couple of key scenarios that are not currently possible when deploying a Windows game to a system in this way because the necessary functionality is only installed by XNA Game Studio, not by the XNA Framework Redistributable:
Behind the scenes details if you are interested
If you are interested in more details, you can see the data files for the XNA Framework Redistributable 3.0 bootstrapper package by looking at the folder %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\XnaFxRedist30 on a system with XNA Game Studio 3.0 installed. We created this bootstrapper package by using the steps in this MSDN document about creating custom bootstrapper packages.
Summary
Windows game packaging and deployment have been consistent pain points since the first version of XNA Game Studio Express. Hopefully the features that we've added in the XNA Game Studio 3.0 beta will end up being useful in making this process simpler and less error prone. If you are creating Windows games using XNA Game Studio, I encourage you to try out these features in the 3.0 beta and let us know if you run into any troubles using these features and/or have any suggestions for further improvements by posting on the forums and/or reporting bugs on the Connect site.
<update date="9/30/2008"> Clarified that adding project output from a game project or a content project into a setup/deployment project will not work in XNA Game Studio 3.0. Instead, if you plan to use a setup/deployment project, you have to manually add the game binaries and content files to the setu project one-by-one. </update>
<update date="10/20/2008"> Added a note about networking and content building scenarios that are supported on systems that have XNA Game Studio installed, but not on systems that only have the XNA Framework Redistributable installed. </update>
<update date="11/3/2008"> Added a caveat that this information is only applicable in the XNA Game Studio 3.0 beta, and added a link to the updated blog post that I wrote about Windows game deployment in the final release of XNA Game Studio 3.0. </update>
Great post. I've been vocal about what a pain point the lack of good setup guidance was, so I'll be similarly vocal about how helpful this post is. :)
With the release of the XNA Game Studio 3.0 beta, some of my colleagues have started posting information
I followed your directions exactly on your blog, I even created a brand new solution with just the cornflower blue, still the same problem. I tried this at work and and home so its not computer or install related. I am using visual studio 2008.
I get the warning from your blog
Warning 1 No 'HomeSite' attribute has been provided for 'Microsoft XNA Framework Redistributable 3.0', so the package will be published to the same location as the bootstrapper. C:\Users\chad\Documents\Visual Studio 2008\Projects\TestInstall\Setup1\Setup1.vdproj Setup1
But then I also get from my error list tab
Error 2 Could not find file 'C:\Users\chad\Documents\Visual Studio 2008\Projects\TestInstall\TestInstall\Content\obj\x86\Debug\Content.dll' 'The system cannot find the file specified.' C:\Users\chad\Documents\Visual Studio 2008\Projects\TestInstall\Setup1\Setup1.vdproj Setup1
Error described a little different from the Output tab
ERROR: Could not find file 'C:\Users\chad\Documents\Visual Studio 2008\Projects\TestInstall\TestInstall\Content\obj\x86\Debug\Content.pdb' 'The system cannot find the file specified.'
When I create my setup project, I go to Setup > add > project output > Primary Output > OK. Which with cornflower blue project should be all I need. Let me know whats up, probably just a beta bug that was missed.
Hi Cpyburn78 - I can reproduce this error on my system as well, but this is not a supported scenario for XNA Game Studio 3.0. The way I am able to get into this error state is by selecting the primary output from the content project (which is the one selected by default when you right-click on your setup project and choose Add | Project output... | Primary output).
An XNA Game Studio content project does not have traditional binary output like a C# project, but it still appears in the Add Project Output Group dialog for a setup project in VS. You can select your game project in the Project dropdown in the Add Project Output Group dialog, and that will add the binary output of your game project to the MSI that is built and will not result in any build errors. However, doing that will not automatically add the output of the content project to your MSI so you will still need to manually populate your MSI with the content needed by your game at run time.
In XNA Game Studio 3.0, the supported way of getting the content project output automatically added is to use ClickOnce as opposed to a setup project. That is why the instructions in my blog post say "Use the designers to populate the project with the payload of your game (content plus game binaries)." instead of saying that you should use the Add Project Output Group dialog. I will update the text of that blog post to be more clear for the future.
Also, note that the behavior you are seeing for a setup/deployment project in this scenario is no different than it was in XNA Game Studio 2.0. We made a decision to invest in improvements in the ClickOnce packaging scenario and integration into the Visual Studio bootstrapper creation process in XNA Game Studio 3.0, but did not have the necessary resources to also improve the setup/deployment project scenario.
Another question, in my xna game I use the projects content folder to get the name of some resources as follows:
this.mainDirectory = new DirectoryInfo("../../../Content/" + Global.WORLDFOLDER + "/");
this.tileFileInfo = mainDirectory.GetFiles();
the application explodes telling me it cant find the folder specified. Since it is always installed in a random folder how can I fix this? I cant put c:\users\name\appdata cause of the random folder location, and its not liking ../../../Content which works find in visual studio debug and release. I tried
this.mainDirectory = new DirectoryInfo("D:/CPyburn3/CPyburnEngine/Content/images/");
where I put a content folder with my images in it and it works fine. anyways I need help on what to do from here.
Last week we had to bid farewell to Charles Cox , content producer and all-around swell guy. Thankfully,
Hy Cpyburn78 - I'm sorry for the delay, I've been on vacation for a little while.
When using ClickOnce, the Content directory will be deployed to the same path as your game EXE. Instead of trying to build a relative or full path like that, could you try to do something like the following:
1. Retrieve the path of the EXE while it is running by using reflection (Assembly.GetExecutingAssembly or something like that)
2. Remove the name of the EXE from the path
3. Append a Content subdirectory name
4. Use this path to retrieve your content files
Hopefully this helps.
I have been trying to use Clickonce to create a setup package for a GS3 windows game. The created set up fails to include xnafxredist30 that you mention in your article. I retried several times. Any idea why this might not be getting included? It does not appear on the list of pre-requisites I can choose to add either. As far as I am aware I installed GS3 beta in the usual way. Any URL you could point me to that could resolve this would be very helpful.
Further to this last I went looking in
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages
and there is no sub-folder for xnafxredist30.
This is presumably why it doesn't appeart on list of pre-requisites to add. And possibly why its not included in the first place.
Any idea why it might be missing from this folder? Am I right in thinking it should have been installed when I installed the GS3 beta?
Hi dorchester_software - If you are using the beta version of XNA Game Studio 3.0, there should be a bootstrapper package for the XNA Framework Redistributable 3.0 installed to the folder %ProgramFiles%\Microsoft SDKs\Windows\v6.0a\Bootstrapper\Packages\XnaFxRedist30. If it is not in that folder, that is why it doesn't appear in the UI in Visual Studio and doesn't get included when you use ClickOnce to deploy your game.
I've got a couple of follow-up questions for you:
1. Can you confirm that you have the XNA Game Studio 3.0 beta installed and not the CTP?
2. If so, what edition(s) of Visual Studio do you have installed?
3. Do you have the following registry value on your system, and if so, what is it set to:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\GenericBootstrapper\3.5]
Path
4. Can you post the following setup log file from your system to a file server so I can take a look: %temp%\XNA Game Studio 3.0 Setup\Logs\redists*.log
Ah! Perhaps it is the CTP I have installed! Would that explain why I don't have xnafxredist30?
If so I will just wait for the 30th October release of GS3, and I'm thinking I'll be sorted.
Thanks!
Hi dorchester_software - Yes, if you have the CTP, you won't have any ClickOnce packages for the XNA Framework Redistributable 3.0. ClickOnce integration was not added to XNA Game Studio 3.0 until the beta. If you would like, you can try this functionality out in the current beta (see http://go.microsoft.com/fwlink/?LinkId=121507 for install information). Alternatively, you can wait for the final release of the XNA Game Studio 3.0 on October 30th.
PingBack from http://www.igrophile.com/aaron-stebners-weblog-clickonce-publishing-integration-and/
XNA Game Studio 3.0 に追加した新しい機能の一つに、 XNA Framework ベースの Windows ゲーム向けの機能 ClickOnce パブリッシングがあります。 Aaron
When the XNA Game Studio 3.0 beta was released a couple of months ago, I wrote a blog post describing
Problems deploying my game. The dreaded 260 character limit rears it's ugly head again!
Error 9 Unable to copy file "bin\x86\Debug\Content\Game\Effects\DeferredRenderingx\deferredShadowedLighting.xnb" to "bin\x86\Debug\app.publish\Application Files\My Game Name Here_1_0_0_0\Content\Game\Effects\DeferredRenderingx\deferredShadowedLighting.xnb.deploy"
The problem is that that path looks suspisciously more like 150 characters, not 260! It's not even the deepest path structure in my game...
Obviously there's not much I can do to reduce the length of names in the structure of my game - short of naming them obscure things.
Should I be looking at other software for deployment, or am I missing something obvious?