In our project, we\'d like to have our TFS build put each project into its own folder under the drop folder, instead of dropping all of the files into one flat structure. To
Here's a very simple solution that requires no modification to source files or project files. When setting up your build definition's Process -> Projects to Build, instead of specifying your .sln file in the projects to build, add each project (.csproj or .vbproj). Now inside the "Run MSBuild for Project" step of your workflow, change the OutDir property to the following:
outputDirectory + "/" + serverBuildProjectItem.Substring(serverBuildProjectItem.LastIndexOf("/"), serverBuildProjectItem.Length - serverBuildProjectItem.LastIndexOf("/")).Replace(".csproj", String.Empty)
This will place each project's build output in to a subdirectory named after the project.
I figured out a nice way to do it. It turns out that since you can set the OutDir to whatever you want within the workflow, if you set it to the empty string, MSBuild will instead use the project-specific OutputPath. That lets us be a lot more flexible. Here's my entire solution (based on the default build workflow):
In the Run MSBuild task, set OutDir to the empty string. In that same task, set your CommandLineArguments to something like the following. This will allow you to have a reference to the TFS default OutDir from your project:
String.Format("/p:CommonOutputPath=""{0}\\""", outputDirectory)
In each project you want copied to the drop folder, set the OutputPath like so:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath Condition=" '$(CommonOutputPath)'=='' ">bin\Release\</OutputPath>
<OutputPath Condition=" '$(CommonOutputPath)'!='' ">$(CommonOutputPath)YourProjectName\bin\Release\</OutputPath>
</PropertyGroup>
Check everything in, and you should have a working build that deploys each of your projects to its own folder under the drop folder.
The steps here don't require a project file modification - http://lajak.wordpress.com/2011/05/07/customize-binaries-folder-in-tfs-team-build/