Setting up Automated Builds in Visual Studio Team Services

Whether you use a Git repository from VSTS or any other external repository such as one on GitHub, you can configure VSTS to perform automated builds for you.

In the setup that I have the repo is within VSTS. Every time I perform a push to master branch, a build gets triggered automatically.
The result is a zip file that contains the built software along with a deployment script which, when executed, copies the files in the required location.

In order to have quick feedback on the state of the software in the repository, automated builds should occur every time the selected branch of the repo gets updated.
An automated build should happen at least on the repo from which the software gets transferred to the subsequent environments.

I will describe the steps on setting up the builds from master branch.

In Visual Studio Team Services go to Build and Release -> Builds:

Then click +New and select the predefined template – in my case that is an ASP.NET Core web application:

You should see the following steps:
– Restore
– Build
– Test
– Publish
– Publish Artifact

In the case of Publish step make sure to set Publish Web Projects and Zip Published Projects to true.
In the case of Publish Artifact make sure that Artifact publish location is set to: Visual Studio Team Services/TFS.

Set the Process Name which will show as the build definition name.

Set the Agent queue to Hosted VS2017.

In Get Sources fill in the From, Repository and Branch which in my case is master. Leave Clean as false, unless you want to run the build on your own private agent – then cleaning might turn out to be useful for debugging.

In Agent Phase leave the settings as they are.

Go to Triggers tab:

and set the Trigger status to Enabled. This will trigger the build on every update of the repository.

Below in Repositories set “Batch changes while the build is in progress” to true.

Finally click Save & Queue. By doing this, you will be able to quickly verify if the build actually succeeds.

Automated Builds are very important in general, but get especially more important when multiple people commit and push the code to the repo. By frequent builds the team are able to quickly identify compile issues or any bugs found during automated Unit Testing step.

The next important phase is the release of software to the target machines. This is the topic of the next post.

Leave a Reply

Your email address will not be published.