Cleaning Publish Folders for TFS/Visual Studio Online

by Tobias Lekman, 24 October, 2017

The data growth a year down the line on our build server is pretty insane. There are nearly a terabyte of files in the Publish folder, even though we run cleanup scripts after each build in the pipeline.

The problem is that the retention in Visual Studio Online does not match what is in the Publish folder as these are never cleared. You need to create a pipeline step or run a script.

I created a script that can be run on a schedule. Here, you need to create a personal access token and replace it below. You also need to enter the tenant name and the project name, plus the build definition numbers you need to retrieve.

To get the build numbers, click the build in VSTO in the browser and check the URL parameter "definitionId".