Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins can't find msbuild

I've installed Jenkins on Windows Server 2012, which all worked fine. However once I tried to configure the MSBuild and VS Code metrics plugins, I get the following error:

C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe is not a directory on the Jenkins master (but perhaps it exists on some slaves)

I've checked the paths and they are correct, but Jenkins can't access them.

Can anyone suggest what may be wrong.

Thanks

like image 982
Lawrence Phillips Avatar asked Jun 04 '14 10:06

Lawrence Phillips


People also ask

Where is MSBuild located?

MSBuild is installed in the \Current folder under each version of Visual Studio, and the executables are in the \Bin subfolder.

How configure MSBuild in Jenkins?

From the Global tool configurations, you can setup MSBuild Configuration. Here, you have to copy the MSBuild.exe path from your system- Program files and paste it to Path to MSBuild textbox. Give a name for your MSBuild and now, apply and save the changes. Select a Freestyle project, click on ok.

Does Jenkins use MSBuild?

Usage. To use this plugin, specify the location directory of MSBuild.exe on Jenkin's configuration page. The MSBuild executable is usually situated in a subfolder of C:\WINDOWS\Microsoft.NET\Framework.

How do I add MSBuild exe to Path?

Click on System and Security and then on System. In the left pane, click on Advanced system settings. At the very bottom of the pop up, click on Environment Variables. Edit the Path variable and append the folder's path that contains the MSBuild.exe to it (e.g., ;C:\Windows\Microsoft.NET\Framework64\v4.


4 Answers

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe

Jenkins was very matter-of-factly lying to you with its requirements. MSBuild.exe is an executable, not a directory just as it reports. The input box expects you to identify the folder containing MSBuild.exe but the Job that executes MSBuild expects you to have provided the file name. The way around this inconsistency between the Job and the Configuration Manager is to Add the MSBuild plugin configuration without providing the name of the executable in the Path to MsBuild input to satisfy the validation requirements of the "Add Plugin" page.

Once the Plugin has been added, you can modify the Path to MsBuild to contain the name of the executable (which, of course, is MSBuild.exe) and rather than a validation error, you will receive a warning.

Ignore the warning. 
Save it anyway.  

It will bypass the initial validation that was required to Add the plug in and will "just work."

Save it anyway

Your Jenkins service will likely still need to be granted access to the file system by "allowing it to interact with the desktop" as was mentioned by other posters. Jenkins service

But your primary problem is that the plug in configuration conflicts with the agent that consumes the configuration and in order to use the plugin to perform builds, you have to use a workaround.

like image 93
K. Alan Bates Avatar answered Nov 02 '22 06:11

K. Alan Bates


I had the same problem, The solution for me was:

If you are running Jenkins as a Window's service, you will probably need to enable the service to interact with the desktop. Do the following:

Open the Services module (press: WindowsKey+R > Services.msc)

  1. Right-click on Jenkins service and select "Properties"
  2. On the "Log On" tab, run as "Local System account" and tick the "Allow service to interact with desktop" checkbox

-- OR --

You can run simply run Jenkins via the command-line. Ie: "java -jar jenkins.war" (jenkins.war file is located in your Jenkins installation Directory).

Cheers,

J.

like image 34
Jibrilat Avatar answered Nov 02 '22 04:11

Jibrilat


Remove the extension ".exe" from the end of the msbuild.exe in your path to avoid warnings: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.

like image 22
Fred Jand Avatar answered Nov 02 '22 04:11

Fred Jand


So you have two servers with Jenkins, one a master (that doesn't have msbuild) and the other a slave (this one does have msbuild). When your job runs (on the master) the msbuild step fails because it doesn't exist on the master.

You need to force your job to only run on the server with msbuild, not the master. Here's how you do this:

  1. Open the configuration for the node that has msbuild on it
  2. In the Labels field add msbuild
  3. Save the node configuration
  4. Open the job configuration
  5. Just above the Advanced Project Options section find the Restrict where this project can run checkbox and check it
  6. In the Label expression field add msbuild
  7. Save the job
  8. Build the job
like image 41
JZimmerman Avatar answered Nov 02 '22 05:11

JZimmerman