There are two approaches :
=============================================
Approach 1
=============================================
To keep the output structure, you have to make TFSBuildHost not pass OutDir
to MSBuild and custom the output path of each project.
- Open the build process file, navigate to Compile the Project Sequence, edit the property of Run MSBuild for Project Activity.
- Set OutDir to empty (just make the textbox is empty)
- set CommandLineArguments to String.Format("/p:SkipInvalidConfigurations=true {0} /p:TeamBuildOutDir=""{1}""", MSBuildArguments, outputDirectory)
- Modify each project file in the solution.
- Check out project file to Edit.
- Open project file with notepad.
- Find <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
- Use following code to replace the default OutputPath Property.
<OutputPath Condition=" '$(TeamBuildOutDir)'=='' ">bin\release\</OutputPath>
<OutputPath Condition=" '$(TeamBuildOUtDir)'!='' ">$(TeamBuildOutDir)\<
ProjectName>\</OutputPath>
The word “Release|AnyCPU” is dependent on the value of “ConfigrationToBuild” in TFSBuild.proj.
- Save project file and check in.
=============================================
Approach 2
=============================================
- Open the build process file, navigate to Compile the Project Sequence, edit the property of Run MSBuild for Project Activity.
- Set OutDir to empty (just make the textbox is empty)
- Set OutDir to System.IO.Path.Combine(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(localProject))
- In the build definition, instead of specifying a single solution, specify the projects individually