title: How can I use a single Visual Studio solution to build both x86 and x64 at the same time?
body: <p>I've got an x86 Visual Studio solution with many project files in it. Some of the DLL files are designed to work as plug-ins to other applications on a user's system.</p>
  
  <p>We're expanding some of the DLL files to be able to support 64-bit applications. I'd like to set up the solution/projects so that just hitting <em>"Build"</em> will build both the x86 and x64 versions of those DLL
  files. The solution contains both C++ and C# projects.</p>
  
  <p>I realize that "Batch Build" is capable of building both, though it would be more convenient if developers could just click the same button as they have previously and have all of the output DLL files generated.</p>
  
  <p>Here are a couple of the modifications that I've tried to a test project, but that I haven't gotten to work:</p>
  
  <p>I've tried modifying the <code>&lt;Target Name="AfterBuild"&gt;</code> to try:</p>
  
  <pre><code>&lt;Target Name="AfterBuild" Condition=" '$(Platform)' == 'x86' "&gt;
    &lt;PropertyGroup&gt;
      &lt;Platform&gt;x64&lt;/Platform&gt;
      &lt;PlatformTarget&gt;x64&lt;/PlatformTarget&gt;
    &lt;/PropertyGroup&gt;
    &lt;CallTarget Targets="Build"/&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>But that results in the following error:</p>
  
  <blockquote>
    <p>C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(565,5): error MSB4006: There is a circular dependency in the target dependency graph involving target "Build".</p>
  </blockquote>
  
  <p>I think my conditions will prevent infinite recursion, but I understand how MSBuild could not see it that way.</p>
  
  <p>I've also tried:</p>
  
  <pre><code>&lt;Project DefaultTargets="MyBuild86;MyBuild64" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"&gt;
  ...
  &lt;Target Name="MyBuild86"&gt;
    &lt;PropertyGroup&gt;
      &lt;Platform&gt;x86&lt;/Platform&gt;
      &lt;PlatformTarget&gt;x86&lt;/PlatformTarget&gt;
    &lt;/PropertyGroup&gt;
    &lt;CallTarget Targets="Build"/&gt;
  &lt;/Target&gt;
  &lt;Target Name="MyBuild64"&gt;
    &lt;PropertyGroup&gt;
      &lt;Platform&gt;x64&lt;/Platform&gt;
      &lt;PlatformTarget&gt;x64&lt;/PlatformTarget&gt;
    &lt;/PropertyGroup&gt;
    &lt;CallTarget Targets="Build"/&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>But my <code>DefaultTargets</code> appears to be ignored from within the Visual Studio IDE.</p>
  
  <p>Last, I've tried creating a separate project that imports the first project:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;Configuration Condition=" '$(Configuration)' == '' "&gt;Debug&lt;/Configuration&gt;
      &lt;Platform&gt;x64&lt;/Platform&gt;
      &lt;PlatformTarget&gt;x64&lt;/PlatformTarget&gt;
      &lt;ProductVersion&gt;9.0.30729&lt;/ProductVersion&gt;
      &lt;SchemaVersion&gt;2.0&lt;/SchemaVersion&gt;
      &lt;OutputPath&gt;..\$(Configuration)\x64\&lt;/OutputPath&gt;
      &lt;ProjectGuid&gt;{A885CAC3-2BBE-4808-B470-5B8D482CFF0A}&lt;/ProjectGuid&gt;
    &lt;/PropertyGroup&gt;
    &lt;Import Project="BuildTest.csproj" /&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>And this so far has shown the most promise. However, Visual Studio seems to ignore my <code>OutputPath</code> setting from this new project and instead outputs the EXE/DLL file to the path specified in the original project. There isn't any <code>PropertyGroup</code> block that I can see that is being executed in the original project to override this, so I'm not sure what's happening.</p>