Build your C++ app for Windows

VSTS | TFS 2017 Update 2

Visual Studio Team Services (VSTS) and Team Foundation Server (TFS) provide a highly customizable continuous integration (CI) process to automatically build your C++ application whenever your team pushes or checks in code. In this quickstart you learn how to define your CI process for a C++ application developed using Visual Studio IDE.

Prerequisites

  • A VSTS account. If you don't have one, you can create one for free. If your team already has one, then make sure you are an administrator of the team project you want to use.
  • While the simplest way to try this quickstart is to use a VSTS account, you can also use a TFS server instead of a VSTS account. Make sure that you have configured a build agent for your team project, and that you have a version of Visual Studio matching your development machine installed on the agent machine.

Get sample app code

To configure a CI build process for your app, the source code needs to be in a version control system. VSTS and TFS integrate with various version control systems such as Git in VSTS or TFS, Team Foundation Version Control (TFVC), GitHub, and Subversion.

For a simple way to follow this quickstart, get the following sample app code and put it into your own version control repository:

https://github.com/adventworks/cpp-sample

To import the sample app into a Git repo in VSTS or TFS:

  1. On the Code hub for your team project in VSTS/TFS, select the option to Import repository.

  2. In the Import a Git repository dialog box, paste the above URL into the Clone URL text box.

  3. Click Import to copy the sample code into your Git repo.

Set up continuous integration

A continuous integration (CI) process automatically builds and tests code every time a team member commits changes to version control. Here you'll create a CI build definition that helps your team keep the master branch clean.

  1. Create a new build definition.

    Navigate to the Files tab of the Code hub, and then click Set up build.

    Screenshot showing button to set up build for a repository

    You are taken to the Build & Release hub and asked to Select a template for the new build definition.

  2. In the right panel, select .NET Desktop, and then click Apply. This template is useful in building most of the Visual Studio solutions including those that contain classic C++ projects.

    You now see all the tasks that were automatically added to the build definition by the template. These are the steps that will automatically run every time you check in code.

  3. For the Default agent queue:

    • VSTS: Select Hosted VS2017. This is how you can use our pool of agents that have the software you need to build your app.

    • TFS: Select a queue that includes a Windows build agent.

  4. Click Get sources and then:

    Observe that the new build definition is automatically linked to your repository.

  5. Click the Copy Files task. Specify the following arguments:

    • Contents: **\$(BuildConfiguration)\**\?(*.exe|*.dll|*.pdb)
  6. Click the Variables tab and modify these variables:

    • BuildConfiguration = debug, release

    • BuildPlatform = x86, x64

  7. Click the Triggers tab and enable the Continuous Integration trigger. This will ensure that the build process is automatically triggered every time you commit a change to your repository.

  8. Click the Options tab and then:

    • Select Multi-configuration.

    • Specify Multipliers: BuildConfiguration, BuildPlatform

  9. Select Parallel if you have multiple build agents and want to build your configuration/platform pairings in parallel.

  10. Click Save and queue to kick off your first build. On the Queue build dialog box, click Queue.

  11. A new build is started. You'll see a link to the new build on the top of the page. Click the link to watch the new build as it happens.

View the build summary

  1. Once the build completes, select the build number to view a summary of the build.

    Navigate to build summary

  2. Notice the various sections in the build summary - the source version of the commit in build details section, list of all associated changes, links to work items associated with commits, and test results. When the build is automatically triggered by a push to your Git repository, these sections are populated with all the relevant information.

Next steps

You've just put your own CI process in place to automatically build and validate whatever code is checked in by your team. You can also automatically deploy your app. To learn more, see one of these topics:

You can also modify this build definition to meet the needs of your team. To learn more see one of these topics: