title: How to only build modified projects when building multiple configurations with MsBuild
body: <p>I have a solution which builds a number of projects.  Some of these projects produce DLLs for redistribution amongst other development teams (for integration). These same DLLs are utilized by our own application and they are primarily modified and updated for the maintenance of this application.
  We have run into the problem that unwanted dependencies are sometimes added to the DLLs we provide to third parties.  As such, we had created a new configuration within our visual studio solution which only builds the DLLs we provide to third parties.  By building this configuration we are able to ensure that our gated-checkin will fail if any new dependencies are added for these projects.</p>
  
  <pre><code>&lt;!-- Build only the Database Access provider DLLs, if a new, unwanted dependency is added, this MsBuild task will fail --&gt;
  &lt;Message Text="Build Database Access Providers"/&gt;
  &lt;MSBuild Condition="'$(Configuration)'=='Release'" Properties="Configuration=Database Providers Release; Platform=Mixed Platforms" Projects="@(MySolution)" Targets="Build" BuildInParallel="$(BuildInParallel)" /&gt;
  
  &lt;!-- ... --&gt;
  &lt;!-- Build all the projects in the solution --&gt;
  &lt;MSBuild Properties="Configuration=$(Configuration); Platform=Mixed Platforms" Projects="@(MySolution)" Targets="Build" BuildInParallel="$(BuildInParallel)" /&gt;
  </code></pre>
  
  <p>The “Database Providers Release” configuration builds each of the required projects in the project’s “Release” configuration.</p>
  
  <p>Because the first call to MsBuild builds the individual projects in the Release configuration and the full build also builds the individual projects in the Release configuration, we thought that the “Build” target would detect that the build outputs are up to date and would skip rebuilding these projects a 2nd time when we execute the second call to MsBuild.  However, the MsBuild script will always rebuild the projects in the second call to the MsBuild task.  This is increasing our build time and impacts our build’s code metrics (for instance the number of build warnings increases because the same warnings are reported twice).</p>
  
  <p>If I simply invoke the solution as a whole twice (using the identical build configuration at the solution level), MsBuild will correctly skip all the solution items (I.e. it performs incremental building of the projects).  E.g:</p>
  
  <pre><code>&lt;!-- Build all the projects in the solution --&gt;
  &lt;MSBuild Properties="Configuration=$(Configuration); Platform=Mixed Platforms" Projects="@(MySolution)" Targets="Build" BuildInParallel="$(BuildInParallel)" /&gt;
  &lt;!— This 2nd build will skip every project as MsBuild detects the projects have been built. --&gt;
  &lt;MSBuild Properties="Configuration=$(Configuration); Platform=Mixed Platforms" Projects="@(MySolution)" Targets="Build" BuildInParallel="$(BuildInParallel)" /&gt;
  </code></pre>
  
  <p>If I run the 2 different build configurations within of Visual Studio directly, it will correctly detect that the various projects have already been built and will skip rebuilding them a 2nd time (I.e. the setup for incremental building of the vcxprojs is correct.)</p>
  
  <p>Is there a way to build 2 solution configurations with MsBuild (where each solution configuration is using the same project configurations) and have MsBuild skip projects which were already built in the first build when they are encountered in the 2nd build?</p>