Custom Build Controller and Agent for Visual Studio Online

TFS

Visual Studio Online offers you a hosted build controller to build your projects directly in the cloud. With every Visual Studio Online account you will get 60 minutes of build time for free. If you are using Visual Studio for your productive projects you will certainly exceed the 60 minutes in a few days. This is no problem at all since you can switch the build resources to paid shared resources (see picture below). The hosted build will then cost about $0.05 per minute which is about $ 3.00 per hour.

image

There are some limitations which could stop you from using the hosted build controller. This blog post will cover how to setup a custom build controller and agent to be used together with Visual Studio online.

Limitations of Hosted Build Controller

The following table shows the limitations of the Hosted Build Controller compared with an on-premise build controller and agent:

Hosted Build Controller On-Premise Build Controller and Agent
predefined Software (link) customize the deployment according to your requirements
supports custom activities and build tasks supports custom activities and build tasks
1 running build at a time scale-out parallel builds with multiple build agents
<= 1 hour build time per build request unlimited build time
<= 75 GB of storage for build unlimited storage (depending on your hardware)
does not run with administrative privileges running with administrative privileges possible
no log on to the build controller / agent log-on / remote desktop possible
build cannot run in interactive mode build can run in interactive mode

Depending on your requirements, there might be a need to use a custom build controller and agent to build your software with Visual Studio Online.

Setup of a custom build controller and agent

To use a custom build controller for Visual Studio Online, we need to setup a build machine the same way as we would do with an on-premise installation of Team Foundation Server. Since we are using the cloud for TFS, it is a good choice to also run the custom build controller an agent in the cloud but you are not limited to it.

Virtual Machine

To start we need a virtual machine with all the development tools configured and then install and configure the Team Foundation Server Build services.

  1. Create a virtual machine in Windows Azure
    image
  2. Instead of installing all development tools from scratch in a clean VM, we can directly use a virtual machine template with the development tools already installed.
    image
  3. Now specify the VM name as well as the administrator account
    image
  4. Additionally we need to define where to deploy our VM. Visual Studio Online runs currently in the West US data center. Therefore we will choose the same location to be near in terms of network communication. In the near future, Visual Studio Online will also be available in other regions.
    image Please note: For demo purposes we just created a VM in the public network. For security reasons it is recommended to create such kind of VMs in a
  5. Now, finish the wizard:
    image

Build Service Configuration

When our virtual machine is up and ready, we need to install the Team Foundation Server build services. We then connect the build controller to our Visual Studio Online Team Project Collection.

  1. Install Team Foundation Server
    image
  2. Configure Build Services
    1. Start the configuration Wizard:
      image
    2. Add the Team Project Collection from your Visual Studio Online account:
      image image image
    3. Configure the build controller and agents:
      image
    4. Define the security credentials for the build service. In this example we are using a dedicated user account “tfsbuild” to run the build service. The connection to Visual Studio Online is done with a special service account from Visual Studio Online. If you need this technical account for your custom tools and scripts, there is a great tool available here from Martin Hinshelwood.
      image
    5. The build controller and agents should now be available:
      image

Create a new Build Definition in Visual Studio

Having configured our new build controller, we now can create a new build definition using our newly created build controller. Go to the team explorer an create a new build definition. In the “Build Defaults” tab, our new build controller is listed as shown below:

image

Verify if the build is running correct:
image

Tags: