TFS2010 Build output to a Custom Folder Structure

How to output TFS2010 build output to a subfolder

The scenario that exists is that I need to build a more detailed tree structure in the build output. I was looking for the least intrusive means of being able to get the build to output to subfolders.

So, I took a branch of the default build template (so I didn’t mess with the rest of the team while I experimented) and started to edit.

 

Drilling through the workflow until you were at the Compile the Project sequence (Overall Build Process; Run On Agent; Try Compile, Test, and Associate Changesets and Work Items; <expand>; Try Compile and Test; Compile and Test; For Each Configuration in BuildSettings.PlatformConfigurations; Compile and Test for Configuration; If BuildSettings.HasProjectsToBuild; For Each Project in BuildSettings.ProjectsToBuild; Try to Compile the Project; and finally Compile the project)

 

I added a new string variable called outputDirForProj scoped for that sequence.

Add in an assign activity setting the outputDirForProj to:

 System.IO.Path.Combine(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(localProject))

Note 1:

I wanted the output to go toProjectFolderOutput

If you want SolutionFolderProjectFolderOutput

System.IO.Path.Combine(outputDirectory, System.IO.Directory.GetParent(System.IO.Directory.GetParent(localProject).ToString()).Name, System.IO.Path.GetFileNameWithoutExtension(localProject))

Of course you could put in a build attribute, and manipulate this whichever way you want to.

The trick is 1) You are in VB and 2) getting the folder name

Note 2:

Your code (or test) project MUST have a name attribute for this to work. (I’ll put that in another post)

 

And after that add a build message (set to high so that I always see it – out of personal preference) with the text

String.Format("Copying build output to {0} ", outputDirForProj)

It ends up looking like:

 

clip_image002

 

Then set the MSBuild task properties to use the added directory

 

 

Check in and the build is ready, then you need to edit the build definition to use target projects, not solutions,

In the build definition, select the individual projects instead of the solutions.

SNAGHTML56ad7e3

SNAGHTML56ce329

and the resulting output will use the project structure.

image

Pin It

Comments are closed.