Managing Cross-Platform Builds and Deployment
When you are developing a cross-platform game in XNA Game Studio, your solution will be composed of a project for each possible platform. You need to understand how to use the features within Visual Studio that control the particular projects that are built and deployed following the Start (F5) key and Build commands.
For example, if you are developing a cross-platform project for both Windows and Xbox 360, you will want to limit game build and deployment solely to the Xbox 360 project when you are trying to develop and debug the Xbox 360 version of the game.
You will need to know how to do the following:
- Set the deployment options to limit builds and deployment to the startup project.
- Set one of the projects in your cross-platform solution as the startup project.
You can also use the Solution Configuration to control the characteristics of the build.
Setting Deployment Options
You can use the Build and Run settings to limit Start and Build commands to the startup project.
To set Build and Run options
- From the Tools menu, click Options...
- If you are using Visual C# Express, make sure the check box in the Options dialog at the bottom left-hand corner labeled Show all settings is checked.
- In the Options dialog, expand the Projects and Solutions node, and select the Build and Run options set.
Check the box labeled Only build startup projects and dependencies on Run (it is unchecked by default).
This setting will limit build and deployment to the startup project.
In addition, you may wish to set the option that automatically sets the currently selected project as the startup project.
To automatically set the startup project
Check the box labeled For new solutions use the currently selected project as the startup project (it is unchecked by default).
This setting will establish that the currently selected project is the startup project. This option will only take effect for new solutions.
Setting the Startup Project Manually
The startup project is the project (or projects) that will be run by Visual Studio when you start the debugger. If you set the Build and Run settings as described previously, the Start command (also initiated by the F5 key) will be limited solely to the startup project (or projects).
Further, if the startup project is set automatically to the currently selected project, it is not necessary to manually set the startup project.
The startup project name always appears in boldface in Solution Explorer.
To set the startup project manually
- In Solution Explorer, right-click the project you wish to set as the startup project.
- In the context menu, click Set as StartUp Project.
You also have the option of either selecting the project in Solution Explorer or, from the Project menu, selecting Set as StartUp Project.
Using Solution Configurations
Solution configurations store solution level properties that direct which style of object and executable output are produced by the Start (F5) key and Build commands. In a cross-platform solution in XNA Game Studio, the solution configuration platform setting is a composite of the platform settings for each project in the solution.
The Solution Configuration control in the Visual Studio toolbar establishes the "Active" (or default) configuration for all projects in the solution. For example, the active configuration may be set to the "Debug" configuration, which includes all symbol information and minimal compiler optimization, or the "Release" configuration. Changing this setting will affect the build of all projects set to the active configuration.
The Solution Platforms control in the Visual Studio toolbar establishes which platform version of the projects in a solution will be built and deployed. In a cross-platform solution, the options may be "Mixed Platforms" (that is, all that are specified in the solution configuration), "x86" (for Windows), "Xbox 360," or "Zune."
For example, if you set the solution platform to "Zune," only the Zune projects in the solution will be built and deployed, but not the Xbox 360 or Windows projects.
Note that this differs from the startup project, which determines which project is run, but not which project is built and deployed. If the Windows project is set as the startup project, but the solution platform is set to "Mixed Platforms," all projects will be built when you press the F5 key, but only the Windows project will execute. Using the previous example, if you change the solution platform setting to "Zune," only the Zune project will be built, but it won't run. The Windows project will not be built, and Visual Studio will run the last built (and perhaps out of date) Windows executable.
To limit Visual Studio to both building and running only the platform version you are currently working on, the solution platform setting should match the platform of the startup project.
You can also limit action to a specific project by right-clicking the project in Solution Explorer, and selecting the desired action (such as Build, Deploy or Debug) that appears in the context menu.
Each project may have its own configuration settings, which may override the active configuration. The project's configurations will also specify the target platform (for example, Windows, Xbox 360, or Zune). The platform settings are set automatically for a project when you use the Create Copy... command to create the synchronized project for a new platform.
To view the project configuration settings
In Solution Explorer, right-click the project to view it, and then click Properties.
In the Project Designer now displayed, click the Build tab.
You can view the project configuration, and change it in the Configuration and Platform settings.