Creating a Build Definition in TFS 2017

Introduction

In my previous post I showed the steps you need to take to create a Build Agent, but you need a Build Definition so you can really build your solution. I also installed Visual Studio 2017 on my buildserver so I can take advantage of the latest .NET Framework in my solution. In this post I will show how to create a default (simple) Build Definition. In production scenarios you will probably need a more complex Definition, but this should get you going.

Creating the Definition

When you open the project you want to create the Definition for in the browser and navigate to the “Build & Release” section you by default will see an empty Definition list.

create_build_definition_1

To create a new Definition it’s as easy as to click “New definition” to start a kind of wizard. You can select a predefined template, but in this example I want to create the Definition from scratch so I will select “Empty”.

create_build_definition_2

With the next step you need to specify the repository you want to use and you can already select the option that this is a Continuous Integration build. You can also select this at a later moment, so you can first try to make your Definition work like you want, and when you are finished configure the Continuous Integration.

create_build_definition_3

You can now select the steps you want to have in your definition. I will use the NuGet Installer, Visual Studio Build and Visual Studio Test steps. You can change the order of the steps after you have added them.

create_build_definition_5

The NuGet Installer step will be used to restore the NuGet packages before building the solution. The Visual Studio Build step will build all solutions that it will find in the configured path, you can also specify a more specific path so when there are multiple solutions in you repository. In my case I have only installed Visual Studio 2017 on my buildserver, so I need to specify “Latest” for the VSTest version setting of the Visual Studio Test step else it will search for the Visual Studio 2015 test runner and you will get an error when running the tests. You can configure more settings for the build like some repository settings, triggers and the retention of the executed builds.

create_build_definition_8

The Definition can’t be used before you save it.

create_build_definition_7

Now you will see the “Queue new build…” option to trigger a build manually.

create_build_definition_9

When you click “OK” the build will be queued and when an Agent is available and has the capabilities to run this build you will see the details of the build. Note that when in this example the Agent with Visual Studio installed is not running you will receive an error with the question if you want to queue the build anyway.

create_build_definition_10

After the build succeeded you can get more info for that build, for instance you can see which changesets are included, the results of the executed tests and if configured the code coverage.

create_build_definition_12

Now your first Build Definition is ready and you can add more steps or tweak the settings to meet your requirements.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s