views:

721

answers:

3

Normally when a Developer compiles a certain mixed C++/C# solution locally on their machine at our company, they employ the use of a .vssettings configuration file. One of the things included in this config file is reference to various directory paths for Lib and Include files.

However, our buildAgent machines (using TeamCity) are set up to be sterile, and have the bare minimum installed on them required to build any given solution/project. This means the above exampled mixed C++/C# project wont have access to the IDE's configuration where things like include search paths were set. TC accounts for this by allowing you to set all sorts of variables for any given buildConfiguration (or even by buildAgent)....

But how do I get an Include search path to WORK in TC? I'm copying down from Source Control (Perforce) a copy local of what I want Included (1), and then trying to define an Environment Variable (2) -- and yet TC fails the build (3).

I'm sure I have something configured wrong, but for the life of me cant figure out what!


Any help would be most appreciated,

blong


(1) VSC Client Mapping - Perforce

//depot/OpenSource/Boost-1.33.0/boost/... //team-city-agent/OpenSource/boost/...


(2) buildConfig Environment Variable definition

env.Include = %system.teamcity.build.checkoutDir%\OpenSource


(3) TC build log snippet

[16:57:39]: [Project "xxx.sln" (Build target(s)):] e:\buildagent\work\ef1853a454da9d94\xxx\rowsbase.cpp(5, 0): error C1083: Cannot open include file: 'boost/dynamic_bitset.hpp': No such file or directory

A: 

Hi,

First, you should try to compile the solution yourself with msbuild or vcbuild on the command line, because TeamCity will do something similar. If necessary, add msbuild folder to the Path system variable. Then open the command line and type:

msbuild.exe YourSolution.sln

or

msbuild.exe YourSolution.sln /p:Configuration=Release

depending whether you want to do so in debug or release mode. This should give the same C1083 errors.

Here's the fix:

  1. Add the path of the directories you need to add an environment variable (in fact, system variable) that I suggest you call INCLUDE.

  2. Open the file VCProjectEngine.dll.config.xml in folder .../Microsoft Visual Studio 9.0/VC/vcpackages/.

Add the INCLUDE system variable to the include line. To me it came to replacing: Include="$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)\include;$(FrameworkSDKDir)include"

with: Include="$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)\include;$(FrameworkSDKDir)include;$(INCLUDE)"

  1. Test it works: Open a new command line (need to after you change environment variables for them to be taken into account) and try to build your solution as shown above. This has worked for me to build C++ solutions with files that #include .

  2. Now let's have it work in TeamCity too. You can run a TC build at this point to see whether it does, but it didn't for me. Go to the "Properties and environment variables" of your TC build configuration, and add an environment variable named INCLUDE with value the same path(s) as in the INCLUDE system variable above.

Now this should work. Hope it helps.

A: 

I ran into a problem were my C++ projects would build in Visual Studio on the build agent, but they failed when built through TC. The build agent is running windows and agent is running as a service (TeamCity Build Agent Service). The problem was that the service was being run as "Local System" instead of the user that configured Visual Studio. I change service so it would log on as the "build" user and everything worked fine.

Jim
A: 

Setting the Build Agent Service to run as a non "local System" account fixed my problem.

Thanks

steve