MSBuild projects are not instrumented under Jenkins

Last edited on

This problem occurs when a project has build without problems under a user account, but the compilation fails when it is run under Jenkins CI. It manifests in compiler errors like this one:

cl : Command line warning D9002: ignoring unknown option ’--cs-on’ [C:\Program Files\Jenkins\workspace\SquishCoco\example.vcxproj]

Here MSBuild has called the compiler directly, instead of calling the wrapper, and the compiler did not understand the CoverageScanner options.

To correct this, it is necessary to set the environment variable LOCALAPPDATA at the beginning of the Jenkins build script. Its value must be the path to the AppData directory of another user, i.e. something like C:\Users\SomeUser\AppData\Local. The build script will then look like this:

set LOCALAPPDATA=C:\Users\SomeUser\AppData\Local "C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "C:\Program Files\Jenkins\workspace\SquishCoco\example.sln" /t:ReBuild /p:Configuration=DebugCoverage