Monday, 27 July 2009

Custom Output Directory for solutions in Team Build

Basically, the problem is that Team Build creates the output of compiled code in a different location than desktop build or in other words when you compile your project locally on your development machine.
I faced this issue because a new website was introduced in one of our solutions with the same name as another project in the same solution.
The only difference between the two were that they were in different directory structure. For this reason, it built fine on the local machine but once on the build server
using team build, the project compiled later overwrote all the website files of the earlier project.

Now, unlike Team Build v1, Orcas does support building using the same output structure as desktop build.

There is a Team Build property called CustomizableOutDir. If you set it to true, the output binaries are created within the same
folder structure rather than to the Binaries root directory. This post from Aaron Hallberg gives a very good account on the
new property.

I tried using that but since I only had to use it in one of my several solutions, I tried using the format


<SolutionToBuild Include="$(SolutionRoot)\Development\...\Solution1.sln">
<Properties>CustomizableOutDir=true</Properties>
</SolutionToBuild>

but it didn't work. Turned out the property needs to be defined in a global PropertyGroup

<PropertyGroup>
<CustomizableOutDir>true</CustomizableOutDir>
</PropertyGroup>
so once I have defined it all solutions would be build in place. So what to do now?
The above mentioned blog post mentions the use of OutDir propertiy. The OutDir property specifies the directory where Tema Build writes all output files.
Similary, there is another property TeamBuildDir is the output directory where Team Build writes the output files by default.

So, to fix the issue that all my solutions, execept for one, keep on writing to the default output directory, I wrote my buid script as follows with the CustomizableOutDir property set to true.


<SolutionToBuild Include="$(SolutionRoot)\Development\...\Solution0.sln" >
<Properties>OutDir=$(TeamBuildOutDir)</Properties>
</SolutionToBuild>


<SolutionToBuild Include="$(SolutionRoot)\Development\...\Solution1.sln" >
<!-- Since this solution needs to build in place, we don't specify the OutDir property-->
</SolutionToBuild>


<SolutionToBuild Include="$(SolutionRoot)\Development\...\Solution1.sln" >
<Properties>OutDir=$(TeamBuildOutDir)</Properties>
</SolutionToBuild>

I hope this solution is useful for other poeple as well. If it works (or not work) for you, please do not hesitate to leave a comment.

No comments: