Search code examples
visual-studio-2008msbuildtfsbuild

Team Foundation Build drops in flat directory structure


I'm trying to "fix" a build on our TF Server that drops everything into the drop folder in one big flat drop (rather than in seperate project dumps like a local build would do), and I'm getting a little frustrated - I'm going to be honest and say this is the first time I've ever worked with MSBuild and this has kind of been droppped on me - it's not a build file I configured from scratch.

I've found a bunch of solutions online, and most point to this blog, which looks good. Unfortunately it doesn't seem to solve my problems at all.

In TFSBuild.proj I have a lump of code that looks like:

<SolutionToBuild Include="$(BuildProjectFolderPath)/../../mySolution.sln">
 <Targets>SomeProject\Project</Targets>
  <Properties>
    CustomizableOutDir=true;
  </Properties>
</SolutionToBuild>

And as far as I can tell from that CustomizableOutDir is indeed set to true which should allegedly retain directory structure. I tried editing some of the project files as indicated in the blog, like so...

<Target Name="AfterCompile" Condition="'$(TeamBuildOutDir)' != ''">
    <ItemGroup>
       <CompileOutputs Include="$(OutDir)\**\*" />
    </ItemGroup>
    <Copy 
      SourceFiles="@(CompileOutputs)"
      DestinationFolder=
      "$(TeamBuildOutDir)\ProjectName\%(RecursiveDir)" />
</Target>

But that behaves weirdly - if I edit several project files I begin to get what looks like I might be approaching a correct solution, but still isn't good enough - I get a directory structure that contains folders like MyProj1 and MyProj2, yet MyProj2 seems to of had all the output from MyProj1 dumped into it (MyProj1 works as I'd hope it to). On top of this the drop folder still has everything else dumped in one big drop (the directories contain duplicates of this drop).

Does anyone have any idea of what could be causing CustomizableOutDir to not behave as expected? Or is there a problem with my csproj file code?


Solution

  • I've seen several suggestions about how to pass the CustomizableOutDir property to msbuild for a solution.

    1. As you has provided in the question, add <Properties>CustomizableOutDir=true</Properties> for the SolutionToBuild Item. (What's the best way to get TFS to output each project to its own directory?)
    2. Add <CustomizableOutDir>true</CustomizableOutDir> to the main PropertyGroup (TFS Build 2008 - Custom output directories)
    3. Add /p:CustomizableOutDir=true to TFSBuild.rsp (TFS Build 2008 - Custom output directories)

    I've tried all three approaches and the last option (TFSBuild.rsp command line option) was the only one I could get working. I combined this with conditions on each OutputPath in the csproj files rather than a AfterCompile Target. E.g.

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <OutputPath Condition=" '$(TeamBuildOutDir)'=='' ">bin\debug\</OutputPath>
        <OutputPath Condition=" '$(TeamBuildOUtDir)'!='' ">$(TeamBuildOutDir)projectName</OutputPath>
    </PropertyGroup>