title: Can Visual Studio 2012 do a custom build such as: compile project A > compile and link project B > link project A?
body: <p>I am looking for a way to builds projects in this order with Visual Studio 2012 (C++ but might be a general question):</p>
  
  <ul>
  <li>Compile ProjectA (I just need the .objs)</li>
  <li>Compile and link ProjectB</li>
  <li>Link ProjectA</li>
  </ul>
  
  <p>I can't simply use a reference/dependency of ProjectA in ProjectB because it will perform the link of ProjectA too early.</p>
  
  <p>I used to do this with VS 2008 this way:</p>
  
  <ul>
  <li>PreBuild Event on ProjectB: <code>vcbuild /pass0 /pass1</code> ProjectA</li>
  <li>Compile and link ProjectB (which is a dependency of ProjectA)</li>
  <li>Compile (actually does nothing as it was already built) and link ProjectA</li>
  </ul>
  
  <p>But vcbuild is gone from VS 2012 and I replaced the command with:</p>
  
  <p><code>msbuild /t:BuildGenerateSources /t:BuildCompile</code></p>
  
  <p>The problem here is that at the 3rd step where it's supposed to only link (since msbuild already compiled) it now <strong>compiles again ProjectA</strong> and then links it. Enabling diagnostic verbosity with msbuild showed me this: <em>Forcing rebuild of all source files due to a change in the command line since the last build.</em>. And pretty much no one (including <a href="https://stackoverflow.com/questions/7559972/visual-studio-2010-randomly-says-the-command-line-changed-and-rebuilds">Visual Studio 2010 randomly says the command line changed, and rebuilds</a>) has a solution for this as it's impossible to see what 2 commands are being compared.</p>
  
  <p>The other benefit of doing what I'm looking for directly with Visual Studio (without a prebuild event that launches msbuild in a command line), would be to have compile errors reported to the Errors list and clickable in the Output window.</p>
  
  <p>Maybe under the hood this would use msbuild and Targets specified in vcxprojs but I'd like to know if it's doable at all.</p>
  
  <p>Edit: I have already tried to replace the command calling msbuild by devenv but there is no switch for devenv that can specify compile only (no linking), so it can't be used either.</p>
  
  <p>Edit2: Sound like someone already asked something similar here (no solution) <a href="https://stackoverflow.com/questions/11347927/is-it-possible-for-visual-studio-c-to-compile-objects-without-linking">Is it possible for Visual Studio C++ to compile objects without linking</a></p>