Because I have several builds sharing some assemblies containing common build tasks, I have one TFSBuild.proj for all builds and import different targets depending on the build, like the following:
<Project DefaultTargets="DesktopBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<Import Project="Build_1.targets" Condition="'$(BuildDefinition)'=='Build_1'" />
<Import Project="Build_2.targets" Condition="'$(BuildDefinition)'=='Build_2'" />
<Import Project="Build_3.targets" Condition="'$(BuildDefinition)'=='Build_3'" />
</Project>
Each target for a particular build has your usual content for a build type file, but in my case, I also reference some tasks inside assemblies checked into the same folder as TFSBuild.proj in source control. I wanted to add folders to contain some test build targets, since my folder was getting a bit full and cluttered. The following illustrates what I mean.
$(TFS project)\build\
TFSBuild.proj
Build_1.targets
...
Assembly1.dll
Assembly2.dll
...
Folder\
Test_target_1.targets
....
When I stated my build, however, I found that Test_target_1.targets and other files in Folder were not being copied to the build directory, while TFSBuild.proj and other files in the root level, as it were, of the build type folder were being copied. This caused my test build to not be able to reference files inside Folder, causing my build to immediately fail. In other words,
$(TFS project)\build\
TFSBuild.proj
Build_1.targets
...
Assembly1.dll
Assembly2.dll
...
Folder\
(nothing here)
I realize the simplest work-around would be to get rid of Folder and move all of its contents up to the build folder, but I would really like to have Folder if at all possible. Thanks for your help in advance.
With Team Build 2008, there’s a setting on the build machine you need to change to get it to download subdirectories in the build folder – add this to the TFSBuildService.exe.config file:
To add it, you need to stop the build service, edit c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\TFSBuildService.exe.config, then restart the service.
The only caveat is you need to remember to do this on any future build machines. But it's pretty obvious what the problem if you forget.
Incidentally, this setting is exposed in the build options in 2010, which is a little more convenient.