C++ – Configuring Visual Studio to create 32-bit and 64-bit configurations

64-bitcvisual studiox86

I'm currently trying to configure Visual Studio to automatically set up the appropriate configurations for 32-bit and 64-bit compilation.

Ideally, I'd like to be able to have Visual Studio automatically show x64 as a platform under the Configuration Manager.

How can I configure VS so any new project I create has this?

Thanks!

Best Answer

Visual Studio 2010 and 2008 both provide a way to do this.

Project Templates are used by VS to create new projects. These templates can be copied and updated as alternate versions or the originals can even modified in place. You can either use the VS editor to modify the Project Template or you can do it manually; it's your choice:

To use the Visual Studio editor:

  1. Create a new project
  2. Configure the Project and Build Configuration settings the way you'd like to see all future projects of the same type configured. In your case, you'll want to add "x64" to the Configuration Manager, then use it in your project's configurations.
  3. Export the project as a template: File -> Export Template

To dig into the Project Template files yourself:

Project Template files are stored here: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates

An example is the Windows Forms Application project template, which is housed in this ZIP file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1033\WindowsApplication.zip

The ZIP file contains a handful of files that form the structure of the project (ie: form1.cs) and contain templatized versions of what you get when you create a project of this type.

The important file you'll want to modify is: windowsapplication.csproj. The name of the file will be different for each template, but the .csproj will remain consistent. It is the templatized project file, so modifying this will modify the project settings for all future projects made from this template.

To modify it, simply extract it from the ZIP, make your changes, then put it back into the ZIP file, overwriting the existing one.

In all cases, the result will be:

Now, when you create a new project of that type in the future, just pick YOUR template instead of the default one and you'll have x64 as a Configuration. You can even share the configuration with your friends since it's stored as a ZIP file.

This MSDN page documents the steps needed for 2010. Click "Other Versions" at the top of that page to see the instructions for VS 2008:

http://msdn.microsoft.com/en-us/library/ms185319(v=VS.100).aspx