Build your C++ app for Windows

Last Update: 6/13/2017

Team Services | TFS 2017 | TFS 2015 | Previous versions: XAML Build, Release

Here we'll show you how to create a continuous integration (CI) build to automatically build and test your C++ Windows app whenever your team checks in code. This build will also automatically supply your team with artifacts of your application, which you can use for debugging old builds.

Get set up

For the instructions in this topic, you need a C++ project in Visual Studio.

TIP

If you don't yet have an app but want to try this out, then see the Q&A below.

Create the build definition

In this section we'll create a build definition for your C++ app.

  1. Open your team project in your web browser ▼

    Browse to team project

    (If you don't see your team project listed on the home page, select Browse.)

    • On-premises TFS: http://{your_server}:8080/tfs/DefaultCollection/{your_team_project}
    • Visual Studio Team Services: https://{your_account}.visualstudio.com/DefaultCollection/{your_team_project}

    The TFS URL doesn't work for me. How can I get the correct URL?

  2. Create a build definition (Build & Release tab > Builds) ▼

    Build tab

  3. On the Create new build definition dialog box, select Visual Studio, and then click Next.
  4. As the repository source, select the team project, repository, and branch, set the option for continuous integration, and click Create. The continuous integration option is what tells Team Services to queue a build when new code is committed or checked in.

Build steps

On the build tab you'll see build steps.

IMPORTANT

Make sure the Copy Files step is set up to copy the artifacts that your team needs. See below for an example.

Package: NuGet Installer
Package: NuGet Installer

Install your NuGet package dependencies (if you have any).

icon
Build: Visual Studio Build

Build the solution.

  • Solution: **\*.sln
  • Platform: $(BuildPlatform)
  • Configuration: $(BuildConfiguration)
icon
Test: Visual Studio Test

(Optional) Run your tests.

icon
Build: Index Sources & Publish Symbols

(Optional) Index your source code and publish symbols to a file share.

icon
Utility: Copy Files

Copy your binaries to the artifacts staging directory.

  • Source Folder: $(Build.SourcesDirectory)
  • Contents: **\$(BuildConfiguration)\**\?(*.exe|*.dll|*.pdb)
  • Target folder: $(Build.ArtifactStagingDirectory)
icon
Utility: Publish Build Artifacts

Copy (publish) the build artifacts to a folder for the release definition.

  • Path to publish: $(Build.ArtifactStagingDirectory)
  • Artifact name: drop
  • Artifact type: Server

Variables

On the Variables tab define these variables:

Name Value
BuildConfiguration debug, release
BuildPlatform x86, x64

Options

On the Options tab:

  1. Select Multi-configuration.

  2. Specify Multipliers:

    BuildConfiguration, BuildPlatform
    
  3. Select Parallel if you have multiple build agents and want to build your configuration/platform pairings in parallel.

Triggers

On the Triggers tab, make sure Continuous integration (CI) is selected and that you're including the branches you want to build. For example, if you want the build to run for any branch, you can include *.

Optionally, you can specify that your build is run on a schedule. For example, you can make it a nightly build.

Queue and test the build

Save the build definition and then select Queue new build. Once the build is done, click the build number (such as "Build 332"), click the Artifacts tab, and then Explore to see the zip file produced by the build.

You'll see something like this:

`-- drop
    `-- ConsoleApplication1
        `-- ConsoleApplication1
            `-- Debug <- (these are for the x86 platform)
                | -- ConsoleApplication1.exe
                | -- ConsoleApplication1.pdb
            `-- Release <- (these are for the x86 platform)
                | -- ConsoleApplication1.exe
                | -- ConsoleApplication1.pdb
            `-- x64
                `-- Debug
                    | -- ConsoleApplication1.exe
                    | -- ConsoleApplication1.pdb
                `-- Release
                    | -- ConsoleApplication1.exe
                    | -- ConsoleApplication1.pdb

To change the artifacts this build produces, modify the copy step arguments.

Q&A

How do I create a C++ solution to play with?

  1. In Visual Studio, connect to your team project.

  2. On the Team Explorer home page (Keyboard: Ctrl + 0, H), under Solutions, click New.

  3. On the New Project dialog box, in the tree on the left side, select Templates > Visual C++. In the list in the middle select Win32 console Application.

  4. On the Win32 Application Wizard dialog box, click Next, and then click Finish.

  5. Either share your code with Git and Visual Studio or share your code with TFVC and Visual Studio.

For more information, see C++ Windows app.

Can Visual Studio project settings affect my CI build?

Yes, if you modify the settings of projects in your solution, this can affect your CI build. For example, in Visual Studio you modify the Output Directory property on the General page. If you removed $(Configuration) from the setting, it could cause problems in your CI build.

I use Team Foundation Server on-premises and I don't see some of these features. Why not?

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.