Background:
I am currently using VS2010.
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.
(MSBuild is run via Cruise Control .NET like so:)
<cb:define buildArgs="/noconsolelogger /p:Configuration=$(configuration);Platform=$(platform) /maxcpucount /v:minimal /nologo" />
<!-- ... -->
<cb:define name="buildSolution">
<msbuild>
<executable>$(msbuildExe)</executable>
<workingDirectory>$(localWorkingDirectory)</workingDirectory>
<projectFile>$(solutionfile)</projectFile>
<buildArgs>$(buildArgs)</buildArgs>
<targets>build</targets>
<timeout>7200</timeout>
<logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</cb:define>
Thus, I solve this issue by using a non-linking project reference:
<!-- Inside ProjectB.csproj -->
<ProjectReference Include="..\ProjectA\ProjectA.vcxproj">
<LinkLibraryDependencies>false</LinkLibraryDependencies>
<Project>{GUID}</Project>
<Name>ProjectA</Name>
</ProjectReference>
In this case, ProjectA is a SWIG project that generates CS source files to be compiled into ProjectB. I accomplish this like so:
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="..\ProjectA\generated\cs\*.cs" />
</ItemGroup>
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:
<ItemGroup>
<CSFile Include="..\ProjectA\generated\cs\*.cs" />
</ItemGroup>
<Target Name="Build" DependsOnTargets="BeforeBuild">
<Csc Sources="@(CSFile)" References="@(Reference)" OutputAssembly="$(OutputPath)$(AssemblyName).dll" TargetType="dll" />
</Target>
Actual Issue:
It seems like MSBuild is no longer respecting the project reference, so it will usually try to build ProjectB before ProjectA.