title: How can I force MSBuild to respect project dependencies in my solution when my project uses a Csc task?
body: <p><strong>Background:</strong></p>
  
  <p>I am currently using VS2010.</p>
  
  <p>There is a known issue with MSBuild where project dependencies in a solution work when building from the IDE, but do not work when the solution is built through MSBuild.</p>
  
  <p>(MSBuild is run via Cruise Control .NET like so:)</p>
  
  <pre><code>&lt;cb:define buildArgs="/noconsolelogger /p:Configuration=$(configuration);Platform=$(platform) /maxcpucount /v:minimal /nologo" /&gt;
  &lt;!-- ... --&gt;
  &lt;cb:define name="buildSolution"&gt; 
    &lt;msbuild&gt;
      &lt;executable&gt;$(msbuildExe)&lt;/executable&gt;
      &lt;workingDirectory&gt;$(localWorkingDirectory)&lt;/workingDirectory&gt;
      &lt;projectFile&gt;$(solutionfile)&lt;/projectFile&gt;
      &lt;buildArgs&gt;$(buildArgs)&lt;/buildArgs&gt;
      &lt;targets&gt;build&lt;/targets&gt;
      &lt;timeout&gt;7200&lt;/timeout&gt;
      &lt;logger&gt;C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll&lt;/logger&gt;
    &lt;/msbuild&gt;
  &lt;/cb:define&gt;
  </code></pre>
  
  <p>Thus, I solve this issue by using a non-linking project reference:</p>
  
  <pre><code>&lt;!-- Inside ProjectB.csproj --&gt;
  &lt;ProjectReference Include="..\ProjectA\ProjectA.vcxproj"&gt;
    &lt;LinkLibraryDependencies&gt;false&lt;/LinkLibraryDependencies&gt;
    &lt;Project&gt;{GUID}&lt;/Project&gt;
    &lt;Name&gt;ProjectA&lt;/Name&gt;
  &lt;/ProjectReference&gt;
  </code></pre>
  
  <p>In this case, ProjectA is a SWIG project that generates CS source files to be compiled into ProjectB. I accomplish this like so:</p>
  
  <pre><code>&lt;ItemGroup&gt;
    &lt;Compile Include="Properties\AssemblyInfo.cs" /&gt;
    &lt;Compile Include="..\ProjectA\generated\cs\*.cs" /&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>However, although this works fine when building through the IDE, it includes none of these files when building through MSBuild. I was able to get it to work by adding the following:</p>
  
  <pre><code>&lt;ItemGroup&gt;
    &lt;CSFile Include="..\ProjectA\generated\cs\*.cs" /&gt;
  &lt;/ItemGroup&gt;
  &lt;Target Name="Build" DependsOnTargets="BeforeBuild"&gt;
    &lt;Csc Sources="@(CSFile)" References="@(Reference)" OutputAssembly="$(OutputPath)$(AssemblyName).dll" TargetType="dll" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p><strong>Actual Issue:</strong></p>
  
  <p>It seems like MSBuild is no longer respecting the project reference, so it will usually try to build ProjectB before ProjectA.</p>