New Visual Studio features in the XNA Game Studio 3.0 beta - multiple content projects and cross-platform synchronization

There are a couple of new features that have been added in the XNA Game Studio 3.0 beta that are intended to improve the development experience in Visual Studio that I want to briefly introduce.  If you have a chance, I encourage you to download the XNA Game Studio 3.0 beta and give it a try.  Please let us know if you find any bugs or have any feedback about the features described below or any of the other features in the product by using the Connect site.

Multiple Content Projects

In XNA Game Studio 2.0, the concept of a content project was introduced.  However, each game project was limited to a single content project, which meant that sharing content between games required some additional work (such as creating a game library and including that library in each game project that you wanted to use the shared content in).

In XNA Game Studio 3.0, it is now possible to add and remove content projects directly within a game project.  This allows you to include multiple content projects into your game project.  You can do all of the following:

  1. Add a new content project - to do this, click on your game project in the Visual Studio solution explorer, then click on the Visual Studio Project menu and choose Add New Content Project...Alternatively, you can right-click on your game project in the solution explorer, choose Add, then New Content Project...You will be prompted to provide a unique name, and an additional content project node will be added to your game project.
  2. Add an existing content project - to do this, click on your game project in the Visual Studio solution explorer, then click on the Visual Studio Project menu and choose Add Existing Content Project...Alternatively, you can right-click on your game project in the solution explorer, choose Add, then Existing Content Project...You will be prompted to browse to the location of the .contentproj file that you want to add, and it will be added to your game project.  Note that each content project must have a unique name.
  3. Remove a content project - to do this, right-click on your content project in the Visual Studio solution explorer and choose Remove.

There are several possible uses for this feature.  Here are a couple of examples:

  • Creating a content project that contains assets that you intend to share across multiple games.  For example, you may have a set of terrain assets that you want to group together into a content project and then include in multiple games so they will have the same backgrounds and look-and-feel and so you can make changes to the assets in a central location.
  • More easily managing cross-platform projects that target Windows, Xbox 360 and Zune.  The Zune has a smaller screen resolution and more restrictive memory requirements (described in more detail here), so you could create a Zune-specific low resolution content project, a Windows + Xbox 360 high resolution content project, and a common shared content project in order to manage game assets in this type of scenario.  There is a topic in the XNA Game Studio 3.0 documentation that describes how to configure a cross-platform project in this way - it is located under XNA Game Studio 3.0 | Using XNA Game Studio | Developing Cross-Platform Games | How To: Create a Cross-Platform Game Solution in the help table of contents.

Cross-Platform Synchronization

XNA Game Studio has a feature that allows you to create a game project for one platform (Windows, Xbox 360 or Zune) and then create a copy of that project for one of the other supported platforms.  Behind the scenes, a new .csproj file is created to represent the game for the new platform, and the appropriate changes are made to the .csproj file so references, pre-processor definitions, etc will be configured correctly for the new platform.

When you create a copy of a project for another platform, it will automatically be populated with the same code and content that existed in the original project at the time the copy was made.  However, in previous versions of XNA Game Studio, any future additions, removals or renames to items in one of the projects would cause it to get out of sync with the other project.  Stephen Styrchak posted some information a while ago on his blog about an add-in he wrote to automatically synchronize cross-platform projects in XNA Game Studio 2.0.

Starting in the XNA Game Studio 3.0 beta, we have included built-in support for cross-platform synchronization that is similar to Stephen's add-in.  After creating a game project and then creating one or more cross-platform copies, XNA Game Studio 3.0 will automatically synchronize item additions and renames that occur in any of the projects in the cross-platform group.

It is important to note here that XNA Game Studio 3.0 will only synchronize projects that are in the same solution and are part of a "cross-platform group."  This means that the projects have to have been added to the solution by creating copies of an existing game project as opposed to by using the Add New Project or Add Existing Project options in Visual Studio.  You can tell whether or not 2 .csproj files are a part of the same cross-platform group by looking at the metadata in the project files.  Every XNA Game Studio project should have a property named <XnaCrossPlatformGroupID> that is set to a GUID value.  Projects that are a part of the same cross-platform group will have identical <XnaCrossPlatformGroupID> values in their .csproj files.