Jenkins can't find msbuild
Asked Answered
T

7

10

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

Trolly answered 4/6, 2014 at 10:52 Comment(1)
Ever figure this one out?Carpi
B
18
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.

Boykins answered 12/7, 2015 at 14:1 Comment(4)
My complete mea culpa: Path To MSBuild.exe: C:\Program Files (x86)\MSBuild\12.0\Bin Executing the command cmd.exe /C " "C:\Program Files (x86)\MSBuild\12.0\Bin" jenkins-net-demo.sln " && exit %%ERRORLEVEL%% from C:\Program Files (x86)\Jenkins\jobs\Demo\workspace [workspace] $ cmd.exe /C " "C:\Program Files (x86)\MSBuild\12.0\Bin" jenkins-net-demo.sln " && exit %%ERRORLEVEL%% '"C:\Program Files (x86)\MSBuild\12.0\Bin"' is not recognized as an internal or external command, operable program or batch file. Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failureBoykins
Fixed my answer; hadn't configured jenkins in a while and apparently forgot the little detail that you had to enter the MSBuild plugin configuration with the "path to MSBuild" sans file name so that the [Add] button was available then modify the path with the executable, ignore the warning, then hit [Save] anyway. After making this change, I ran a build of my sample and it succeeded.Boykins
It is an old post but just for help for whoever would end up here, to avoid getting the warinig message remove extension ".exe" from the msbuild something llike below: (msbuld is the exe file not a filder) C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuildStraightlaced
I had a problem where nuget.exe would automatically detect msbuild versions and detect a different version at different times. I tried to use the -MSBuildPath arg but couldn't get it to resolve the path even though the path definitely existed. After adding the MSBuild installation as you suggested my nuget.exe consistently detected MSBuild 15 correctly.Tetracycline
L
7

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.

Lytic answered 12/6, 2014 at 12:5 Comment(0)
S
5

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.

Straightlaced answered 4/4, 2016 at 1:30 Comment(0)
T
3

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
Trepang answered 5/6, 2014 at 17:42 Comment(0)
A
1

I also see the "...is not a directory on the Jenkins master..." error message, but when I try to build it works anyway.

Don't forget to select the MS Build version for your project instead of (default).

See: build .net application in Jenkins using MSBuild

Assign answered 19/6, 2014 at 14:11 Comment(0)
O
0

Well

  • Does C:\Windows\Microsoft.NET\Framework\v3.5\ exist on Master server?
  • Does the Jenkins user have permissions to this folder?
Operator answered 4/6, 2014 at 14:3 Comment(0)
F
0

Looks like this issue has been resolved in the 1.26 release: JENKINS-28679

Frightful answered 14/10, 2016 at 17:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.