Code compile always fails when started from Jenkins never fails outside of Jenkins

I have a project that compiles a solution in three different configurations. The first is a full rebuild of the solution for a windows release. This works fine every time. The second and third are a compile of the same solution for a VisualGDB platform for our linux configurations.

The second and third compiles work fine in Visual Studio, and they work fine when run from msbuild from the command line, but every time I try to build them in Jenkins, whether it be with the build a VS project with msbuild, or by executing a batch command and calling msbuild with the parameters on my own, it fails. The error is always, “Exception has been thrown by the target of an invocation”. Since the visual studio build never throws an error, the developers have said they don’t know what’s wrong.

What changed. We moved to a new Jenkins instance because our old device was failing. We installed and configured jenkins to run the same projects that were running on the old device. The nodes did not change. There are about 2 dozen projects running in the Jenkins instance and all are working except for these two. And there are multiple projects that run on the same node as these two projects, that work perfectly fine.

I’m not sure where to go from here. Any advice?

Without details there’s not a lot we can help with. My guess is that jenkins is running as a service user and doesn’t have something you to compile setup properly (path, license keys, etc).

I would recommend looking for error messages, stack traces, or trying to identify what is different about the build/environment.