Gotchas: Getting C++ Projects Building on a CI Server

Friday, May 1, 2009 – 8:33 AM

The other day I added a VC++ project to my main solution file and all hell broke loose on the TeamCity CI server. Errors like this started appearing.

D:\TeamCity\buildAgent\work\71a700fe606e0795\trunk\NBody.sln error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008.

Needless to say the build went red. Turns out the fix for this is pretty straightforward. Install the Windows SDK and make sure that the build can find it.

Steps to fix

Windows SDK install options.Install the Windows SDK. This downloads as an ISO image so the easiest way to use it is to install a virtual CD/DVD reader like MagicDisc. You need to install the windows headers and libraries and the Win32 tools. You don’t need to install the whole thing, just the headers and libraries required for VC++ assuming you have the latest versions of .NET already on the machine.

In the image on the right you’ll see that the Win32 developer tools are selected as are x86 and x64 libraries. You need the Win32 Development tools as the C++ compiler uses some of these.

 

Setting up the environment PATH.Add C:\Program Files\Microsoft Visual Studio 9.0\VC\vcpackages to the system PATH variable. This is one the Advanced tab of the System Properties (see left).

You may have to restart the CI service in order to get it to pick up the changes. TeamCity allows you to restart the agent which seemed to do the trick but this may vary depending on which CI tool you’re using.

 

 

Some things may still not work right without installing Visual Studio on the build server, which is something most people try and avoid. The main example I’ve come across is with WinSxS not finding debug versions of some assemblies, like OpenMP. This means I can build release on the build server but not debug. If your application builds but unit tests fail with loading and file not found errors then this may be the problem. The best place to look for these is in the Windows event log which will record WinSxS errors. This should get you started at least.

Sorry, comments for this entry are closed at this time.