boojum boojum - 2 months ago 21
C++ Question

How to configure teamcity build agent to use include files on system?

I've a project that uses boost headers/libraries for which I would like to create a build configuration for a team city build agent (TeamCity 10.0.2 / Windows 10 / Visual studio 2015). The boost headers/libraries are not part of the project (that is boost is not in git). Instead the boost headers/libraries on the development machines are located relative to the project files (for example $(SolutionDir)........\boost_1_59_0).

The build with the build agent fails because the boost header files can't be found. To resolve this I've tried to:


  • use a fixed location (for example C:\boost_1_59_0) and put boost on the same location on the machine where the build agent runs but that doesn't help.

  • creating an environment variable INCLUDE and set it to to the location of boost. It shows up in the environment variables of the build agent in the team city web interface.

  • copying boost to the build agents work directory doesn't work because the build agent removes the directory.

  • setting the build agent/teamcity webserver to run as a non "local system" account.



How can the build agent be configured so that it knows where to find the boost libraries?

Answer

In your build configuration create a new build step before sln build which copies boost headers into proper folder. Use Command Line Runner together with xcopy command to do this.

Command line can use source checkout directory:

xcopy /Y /E "E:\local_boost_install_folder" "%system.teamcity.build.checkoutDir%\src\boost_1_59_0"

One more approach is to set script Working Directory to %system.teamcity.build.checkoutDir%\src\ and create directory link:

mklink /D boost_1_59_0 "E:\local_boost_install_folder"