How to target both Win32 and x64 platforms with ONLY one set of solution/project files?

7.9k views Asked by At

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?

2

There are 2 answers

0
Michael Price On

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..."

1
sll On

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: