Uutiset

Adafyn kuulumisia

Setting Up Build Into Visual Studio Team Services

Visual Studio Team Services (VSTS) offers a nice set of tools for CI builds. In this blog post I’m going to show you how to setup a automatically triggered build environment for basic ASP.NET MVC web project. CI builds aren’t restricted for ASP.NET web sites only, but I think that type of project is one of the most common.

Setting up build

Log into VSTS site and select project from dashboard, or create new one. I’m creating a new project in this post

Creating new project will take a while, but after it’s completed you have a version control system and work mangement task board setup. Next link the given Git url into Visual Studio by finding the project from Visual Studio Team Explorer (Click Manage Connections in Visual Studio Team Explorer and log in with same account as the VSTS project was made).

Next create a new ASP.NET MVC solution or use existing one to get something to use in builds:

Commit your code into source control and push master branch.

Check Code > Files tab to ensure that you have your code in source control.

Creating build definition

Navigate into Build & Releases > Build tab and create a new defition.
Select ASP.NET (PREVIEW) project type to get a nice set of ready made build steps.
On the left side are build steps which are executed on every build. Right side contains parameters for each build step. Select a Hosted VS2017 into Default agent queue selection. This means that our build definition is handled by Visual Studio 2017 type of build agents.
Next link your Visual Studio solution by clicking … button next to path to solution or packages.config textbox. 
Finally remove the Test Assemblies build step by right clicking the task and selecting ”Remove selected tasks”. Click Save & queue button from top right and a new build should start.
Click blue build number to navigate into build log:
Build succeeded! You can download built items from Artifacts link.

Setting up build trigger

Next let’s edit our build definition, and add new build trigger which builds our solution when new code gets committed in. Click Build & Releases tab and start build editor (click … button next to build definition name and select Edit…).
Navigate into triggers tab and Enable ”Continuous integration” trigger
Now our build is run every time something is committed into master branch. VSTS supports also scheduled triggers and custom triggering via Rest API (for example: http://async.codes/trigger-visual-studio-team-services-vsts-ci-build-from-bitbucket/)