5

I'm trying to migrate a multiple-project from VC++2005 to VC++2010, and I also need to port this application from Win32 to x64 platform.

I know that a project file could contain settings for both platforms, but it requires that I have to manully change the platfrom setting for each project say if I want to build for x64.

What I want to do is to have ONLY one set of solution/project files that could target both of these platforms, and with some kind of simple switch I can choose what platform I am building now. Is there such a way? Or do I have to maintain two sets of solution/projects files, one for each platform, so that if I want to build for x64, I can only open the solution file for x64, and if I want to build for Win32, I have to open the solution file for Win32?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
cobe24
  • 221
  • 3
  • 8

2 Answers2

5

You can use the "Configuration Manager" in Visual Studio 2010 to make multiple configurations for your solution and project files.

In the menu bar of VS 2010, go to "Build" --> "Configuration Manager..."

Michael Price
  • 8,088
  • 1
  • 17
  • 24
4

Let's say you've the platform property which duplicates in each project file:

<Platform>x86</Platform>

You can extract this property from ALL project file in a single CommonProperties.properties file:

<?xml version="1.0" encoding="utf-8" ?>
<Project 
    ToolsVersion="4.0" 
    xmlns="http://schemas.microsoft.com/developer/msbuild/2003" 
    DefaultTargets="Default">

    <PropertyGroup>
         <Platform>x86</Platform>
    </PropertyGroup>
</Project>

And then just import it in ALL project files:

<Import Project="CommonProperties.properties" />

EDIT: Multiple platform support

<Platform Condition="'$(Platform)' == 'Win32'">x86</Platform>
<Platform Condition="'$(Platform)' == 'x64'">x64</Platform> 

Useful links:

sll
  • 61,540
  • 22
  • 104
  • 156
  • Thanks, sll. I know that the VC2010 property sheet file(.props) could define some common project settins like user-defined environment variables, then all projects could import this file to share these common settings. But it seems to me that property sheet file doesn't support different configuration(Debug or Release), or different platforms(Win32 or x64), because the UI controls for setting these are grayed out. What I want to do is to define different settings for different configuration/platforms in a single file, and let all projects import this file. – cobe24 Oct 18 '11 at 10:01