Managing Cross-Platform Builds and Deployment

When you develop a cross-platform game in XNA Game Studio, your solution is 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 need to know how to:

  1. Set deployment options to limit builds and deployment to the startup project.
  2. Set one of the projects in your cross-platform solution as the startup project.

You can also use 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

  1. On the Tools menu, click Options.

  2. If you are using Visual C# Express, in the Options dialog box select the Show all settings check box.

  3. In the Options dialog box, expand the Projects and Solutions node, and select Build and Run.

  4. Select the Only build startup projects and dependencies on Run check box (it is cleared by default).

    This setting limits build and deployment to the startup project.

In addition, you may want to set the option that automatically uses the currently selected project as the startup project.

To automatically set the startup project

  • Select the For new solutions use the currently selected project as the startup project check box (it is cleared by default).

    This setting establishes that the currently selected project is the startup project. This option only takes effect for new solutions.

Setting the Startup Project Manually

The startup project is the project (or projects) that are run by Visual Studio when you start the debugger. If you select the Build and Run settings previously described, the Start command (also initiated by the F5 key) is limited 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 bold in Solution Explorer.

To set the startup project manually

  1. In Solution Explorer, right-click the project you want to set as the startup project.
  2. In the context menu, click Set as StartUp Project.

You also can use Solution Explorer to select the project or, on the Project menu, click Set as StartUp Project to select the 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 it may be set to the Release configuration. Changing this setting affects 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 are built and deployed. In a cross-platform solution, options may be Mixed Platforms (that is, all that are specified in the solution configuration), x86 (for Windows), Xbox 360, or Windows Phone. For example, if you set the solution platform to Windows Phone, only the Windows Phone projects in the solution are built and deployed. Xbox 360 or Windows projects are not affected.

Note

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 are built when you press the F5 key, but only the Windows project executes. Using the previous example, if you change the solution platform setting to Windows Phone, only the Windows Phone project is built, but it does not run. The Windows project is not built, and Visual Studio runs 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.

To limit action to a specific project

  • In Solution Explorer, right-click the project, and then select 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 also will specify the target platform (for example, Windows, Xbox 360, or Windows Phone). 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 change project configuration settings

  • In Solution Explorer, right-click the solution, and then click Configuration Manager on the context menu.

    Tip

    You can also start the Configuration Manager by selecting it on the Solution Configurations menu on the toolbar.

See Also

How to: Add a Game Content Project
Developing Cross-Platform Games