Search code examples
.netvisual-studio-2010projectplatformsolution

How to keep a minimum of solution platforms in the configuration manager?


When I create a Class Library project my solution adds an "AnyCpu" platform. After adding a WPF project it adds a "x86" platform. Then when I create a Console project it finally creates a solution-wide "Mixed Platforms" platform. There are 2 problems:

  • When I try to compile it on a 32 bit machine the Debug binary won't work unless I replace all "AnyCpu" references by "x86" in all .csproj files (the Release binary works however)
  • The configuration manager and the .sln files are cluttered

How to avoid those problems?


Solution

  • You can specify all this configuration in a single MSBuild properties file and just import in each csproj so you just neeed to change it in one place going further.

    <!-- Add in the each csproj file -->
    <Import Project="..\CommonProperties.properties" />
    
    
    <!-- CommonProperties.properties file -->
    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0"
             xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
        <PropertyGroup>
          <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
        </PropertyGroup>
    
    </Project>