How to organize VSTS build output into separate folders?

Mar 17, 2018 | Tarun Arora

DevOps Build

I have seen teams not care about the structure of the build artifact, instead add several steps in their release pipeline to unclutter the binaries generated from the build output. It is fairly trivial to control the structure in which the build output gets published as an artifact to your TFS or VSTS build. In the spirit of pushing left (DevOps way of working), in this blogpost I’ll show you how to easily structure the build output in separate folders by using the copy task in the build pipeline.

Problem Statement

I have a solution file which when processed through the build pipeline generates a build output and add’s every folder that has any dll’s into the build output. Let’s double click to see where the real problem is,

  • Folders that I have no interest in have been added as a build artifact

    Deafult buildouput add's all folders that produce dll's in bin directory

  • The folders are nested into sub folders, and sub folders and further sub folders for stuff that I am interested in

    Default build output nested 3 levels in

Solution

A vanilla build pipeline add’s one copy step and one publish step in the build pipeline…

One copy and one publish step in default build pipeline

The build generates the binaries in the $(build.defaultworkingdirectory) folder, the copy step simply copies all the binaries from the default working directory $(build.defaultworkingdirectory) using the format **\bin\$(BuildConfiguration)\** into the artifact staging directory $(build.artifactstagingdirectory)… The publish step as you would expect published everything that it finds in the $(build.artifactstagingdirectory)

The build copy step is your friend if you use it correctly…

Instead of overloading just one copy step to copy everything, I have added multiple copy steps. I’ve qualified each step to full qualify the folders I need to get rid of the multi level hierarchies in the artifact folder, see the example below…

# Fully qualify the location where the binaries are
# this will remove the sub folders from the build output

$(system.defaultworkingdirectory)\xxx\MessageEngine\bin\$(BuildConfiguration)\

# Specify a target folder name where you want the binaries copied
$(build.artifactstagingdirectory)\ME.Service

One copy and one publish step in default build pipeline

With the new copy tasks in, the build output now looks like this…

One copy and one publish step in default build pipeline

I hope you find this useful… #DevOpsOn…

Know a better way of doing this? leave a comment…

Tarun

About author
Author Image
Tarun Arora
Tarun Arora is obsessed with high-quality working software, DevOps, Continuous Delivery and Agile. His core strengths are Azure, VSTS, PowerShell, SQL and WPF. He is a Microsoft MVP in Visual Studio Development Tools and the author of 'DevOps & ALM with TFS 2015'.
Comments