title: Getting MSBuild to compile project with dependencies for Win32 and Win64 platforms
body: <p>I have a large solution with over 10 projects in it, in C++.</p>
  
  <p>The entire solution  is <em>x64</em> only, except for project <strong>P</strong> which needs both both <em>x64</em> and <em>win32</em> versions ( the proper one is loaded at runtime).</p>
  
  <p>Project <strong>P</strong> depends on several other projects for lib files: <strong>C</strong> and <strong>H</strong> which are compiled into libs.</p>
  
  <p><strong>P</strong> has a reference to <strong>C</strong> and <strong>H</strong> like so:</p>
  
  <pre><code>&lt;ProjectReference Include="..\C\C.vcxproj"&gt;
     &lt;Project&gt;{....}&lt;/Project&gt;
  &lt;/ProjectReference&gt;
  &lt;ProjectReference Include="..\H\H.vcxproj"&gt;
     &lt;Project&gt;{....}&lt;/Project&gt;
  &lt;/ProjectReference&gt;
  </code></pre>
  
  <p>I want to build project <strong>P</strong> for both platforms.</p>
  
  <p>I chose to do this from a <strong>meta-P</strong> project, which calls on <strong>P</strong> like so:</p>
  
  <pre><code>&lt;MSBuild Projects="..\P\P.vcxproj" Properties="Platform=Win32"/&gt;
  &lt;MSBuild Projects="..\P\P.vcxproj" Properties="Platform=x64"/&gt;
  </code></pre>
  
  <p>This allows <strong>P</strong> to be changed freely by the developers, and then both versions are built at once by building <strong>meta-P</strong>.</p>
  
  <p>The problem is that when <strong>meta-P</strong> calls MSBuild on project <strong>P</strong> the references to <strong>C</strong> and <strong>H</strong> are affected by the Solution environment (in which the active platform is always x64).</p>
  
  <p>When it comes to linking the Win32 <strong>P</strong> to its proper <strong>C.lib</strong> and <strong>H.lib</strong>, the open solution configuration kicks in, and studio attempts to link it with the x64 version, and fails.</p>
  
  <p>I temporarily solved it using an <strong>exec</strong> task in <strong>meta-P</strong> to run <em>MsBuild.exe</em> directly on <strong>P</strong>. This ignored the Visual Studio environment properties.</p>
  
  <p>What is the correct solution to have the platform correctly read?</p>