I found the following MSDN article useful in fixing this issue: Common MSBuild Project Properties
In my project file I had the following (snipping out the non-relevant bits here such as the files in the project in ItemGroup
's):
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Import Project="$(DepotRoot)\internal\infrastructure\build\BuildDbProj.prop" />
<PropertyGroup>
<Name>FooDatabase</Name>
</PropertyGroup>
I altered the prop file such that it now has an IntermediateOutputPath (the other bits were already there), which now looks like:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Build.prop" />
<PropertyGroup>
<OutputPath>$(FullOutputPath)Databases\$(Name)\</OutputPath>
<IntermediateOutputPath>$(FullIntermediateOutputPath)\$(Name)</IntermediateOutputPath>
<DeploymentPath>$(FullOutputPath)Deployment\DB\$(Name)\</DeploymentPath>
<DeploymentContentPath>$(DeploymentPath)Content\</DeploymentContentPath>
</PropertyGroup>
</Project>
The relevant bits of the Build.prop
file look like:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BranchRoot>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), branch.root))\</BranchRoot>
<BranchingFolderStructure>$(BranchRoot.Replace($(DepotRoot)\internal\, ``))</BranchingFolderStructure>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$(DepotRoot)\obj\$(BranchingFolderStructure)</BaseIntermediateOutputPath>
<FullIntermediateOutputPath Condition="'$(FullIntermediateOutputPath)' == ''">$(BaseIntermediateOutputPath)$(Configuration)\$(Platform)</FullIntermediateOutputPath>
</PropertyGroup>
</Project>
What this now does is redirect the Model.xml to output to the D:\Builds\...\Sources\obj\...\Debug\AnyCPU\FooDatabase
directory, where FooDatabase
is the Name
property in the database project. Now I don't need to change the MSBuild to use BuildInParallel
set to False, etc.