title: Visual Studio 2010 -- selected Solution Configuration affecting Batch Build output
body: <h1>Summary</h1>
  
  <p>I'm having a very strange behavior with Visual Studio 2010, and I'm not sure if it is a bug or if there is some twisted logic to why it is behaving in this way.</p>
  
  <p>The executive summary is that when I use Batch Build->Select All->Rebuild to build all the configurations for all my projects, VS2010 produces differing output binaries depending on what is the currently selected Solution Configuration. This is really annoying because some of the project outputs fail to run correctly (giving a "[Project name] has stopped working" error dialog on startup) <strong>depending on which Solution configuration was selected during the batch build</strong>.</p>
  
  <h1>More details</h1>
  
  <p>I have a Solution with 3 C# projects in it (1 .dll outputting project, referenced by the other 2 .exe outputting projects). Of the .exe outputting projects, <strong>Project A</strong> has <code>Release</code> and <code>Debug</code> Project configurations. <strong>Project B</strong> has a <code>Debug</code>, <code>Release-x86</code>, and <code>Release-x64</code> configuration because it needs some different post-build scripts run to give it the correct version 3rd party libraries.</p>
  
  <p>I have 4 Solution Configurations: <code>Debug</code>, <code>Release</code>, <code>Release-x86</code>, and <code>Release-x64</code>. <code>Release-x86</code> and <code>-x64</code> are set to build only Project B. <code>Release</code> and <code>Debug</code> build Project A and the shared dll project.</p>
  
  <p>If I select the <code>Debug</code> Solution configuration from the current configuration drop-down box, and the Batch Build all, then when I try to run the Release configuration of Project A it fails to run. If I select any other Solution configuration from the drop down, and then Batch Build all, then it runs successfully. When I diff the produced .exe file, I can see that it is different between these two cases. </p>
  
  <h1>Question</h1>
  
  <p>Is this some known intended behavior of VS2010? If so, can someone give a hint as to why this problem may be occurring and how I can fix it? Is this a bug in VS2010?</p>
  
  <h1>Follow-Up Clue? [Edit]</h1>
  
  <p>Could this have something to do with how VS2010 handles "Project references"? As I mentioned, both .exe projects reference the dll Project, call it <strong>Project D</strong>. I added that reference (to Project A, say) by selecting Add Reference -> Project -> Project D. But of course the different configurations of Project A want to use different configurations versions of Project D. When I examine the Project A -> Project D reference under Properties, I see a Path field that is not editable. Depending on which Solution configuration is selected, I either see <code>...\Project D\bin\Release\Project D.dll</code> or <code>``...\Project D\bin\Debug\Project D.dll</code>, and I don't see any way to control this so I guess VS2010 is trying to be smart about picking the details of Project configurations. But even more strangely, if I select Batch Build -> Select All -> Clean  to remove all compiled files, than these reference paths change to <code>...\obj\...</code> instead of <code>...\bin\...</code> when I inspect them, and I can't seem to change them back except by removing and re-adding the project reference.</p>
  
  <h1>Follow-Up 2 [Edit2]</h1>
  
  <p>I lied a little bit earlier, I actually have 2 .dll projects (Projects D and E, say) where D references E through a project reference.</p>
  
  <p>I'm pretty sure something broken or bizarre with Project References in VS2010 is the culprit, and think I have found the root cause of the selected-Solution-Configuration-dependent behavior, with the following steps</p>
  
  <p>1) I Batch Build -> Select All -> Clean, to remove all previously compiled binaries.</p>
  
  <p>2) I select a Debug Solution Configuration from the drop-down.</p>
  
  <p>3) I Batch Build -> Select Only Project A Release -> Rebuild.</p>
  
  <p>By watching the Output window, I see that VS2010 knows that Project A depends on D, and D depends on E, so it attempts to build them in reverse order. It successfully builds the Release configuration of project E. But then it tries and fails to build the Release configuration of project D, because it complains about missing the missing <strong>Debug</strong> version of E dll file. And likewise A fails to build because of the absence of the Debug version of D.</p>
  
  <p>So it seems that the selection Solution Configuration is overriding the configuration of referenced projects in Project to Project references.</p>
  
  <p>Is that supposed to be the case???</p>