Building/Testing with TFS/VSTS

We use TFS 2015 to handle all of our .NET application builds as part of our CD process and it works GREAT!  In this post I will review how we use TFS in each step of the process.

Gated Check-ins

We have used Gated Check-ins for several years now to ensure our code is of high quality before it is checked in.  When a developer attempts to check-in TFS saves the changes as a shelveset a first, runs your gated build with the shelveset and finally commits the checkin only if the build is successful.

In TFS/VSTS, any build can be configured as a Gated Check-in build with the simple check of a box in either TFS or VSTS:

TFS 2015

image

VSTS

image

This assumes you are using a TFVC source control repository.  For GIT repos, you can setup branch policies:

image

Our Gated Check-in builds always verify the code compiles and all the unit tests pass successfully.   In addition, most of these builds also run a post-test PowerShell script which reads the code coverage result from the current build and compares to the last good build to ensure our code coverage hasn’t dropped.  The script utilizes the TFS API to pull these coverage numbers.

In the future we are looking to also include static code analysis via SonarQube.

Package Builds

Next we utilize the TFS/VSTS build system to create MSDeploy packages of our deployable components.  This can include ASP.NET websites, WCF services, Windows Scheduled Tasks, Window Services and SQL Server databases.  We utilize the MSDeployAllTheThings Nuget packages to enable packaging with MSBuild.  In the build definition we specify the project to build along with the MSBuild arguments to trigger MSDeploy packaging:

image

Feature Test Builds

We also have builds for running our feature tests via the Visual Studio Test task.  We used CodedUI initially for all our automated feature testing but have since moved to using Selenium instead.  These builds can build/execute both. 

image

The test results are also displayed as you would expect on the build summary pages:

image

image

Performance Test Builds

Finally, we have performance test builds which run Visual Studio Load Tests so we can track how the performance of our ASP.NET websites are effected with each change.   

image

TFS vs VSTS

We have used TFS since version 2010 and have always been quite happy with it.  TFS 2015 introduced the new build system which is much more powerful and easier to customize. Both are capable of running all of these build types but we are now moving to the newer build system to leverage its improvements. 

I hope this post was helpful.  If so please leave a comment below or mention it on Twitter.

Happy building/testing!

2 thoughts on “Building/Testing with TFS/VSTS”

  1. Pingback: Queue TFS/VSTS builds VIA PowerShell – dotnet catch

Leave a Reply to Samir Behara Cancel reply