##### Child pages
• MSBuild Plugin
Go to start of banner

# MSBuild Plugin

Plugin Information

This plugin allows you to use MSBuild to build .NET and Visual Studio projects.

## 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. The Visual Studio 2017 Community version of "msbuild.exe" is located in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\" If you have multiple MSBuild versions installed, you can configure multiple executables.

Then, on your project configuration page, specify the name of the build file (.proj or .sln) and any command line arguments you want to pass in. The files are compiled to the directory where Visual Studio would put them as well.

### Troubleshooting

• When using Command Line Arguments, bear in mind that special characters are treated like in Unix, so they will need to be escaped using the backslash.

## Changelog

##### Release 1.29

* Fix JENKINS-48194 - Binary compatibility broken since 1.28

##### Release 1.28

* Fix JENKINS-42284 - chcp command errors are ignored and no longer fail the build. Moreover, a checkbox is now available on the build step configuration to prevent the plugin from executing chcp before running msbuild.

##### Release 1.27

* Add JENKINS-24132 - Support for multiple MSBuild Output encoding so that the console log of Jenkins is displayed correctly
* Fix PR#28 - Minor bugs and build warnings

##### Release 1.26

* Fix JENKINS-28679 - Warning when setting MSBuild installation path to the directory containing msbuild.exe instead of the path to the executable itself
* Add JENKINS-3367 - Add ouput coloring for warning and error messages

##### Release 1.25

* Fix JENKINS-9104 - Veto killing mspdbsrv.exe"

##### Release 1.24

* Fix JENKINS-19706 - Masked Password Clearly visible as plain text in console output.
* Fix JENKINS-19830 - Masked Password visible as plain text in Msbuild Plugin
* Fix JENKINS-21585 - Pass build variables as properties incorrectly format command line
* Fix JENKINS-18652 - Handling of Configuration and Platform parameters
* Fix JENKINS-22344 - Command Line Arguments: /p:PublishFolder does not work with UNC format to publish to remote server
* Fix JENKINS-22451 - Backslash is stripped from MSBuild command line argument
* Fix JENKINS-22461 - New MSBuild release has a space in the installation path; causes msbuild plugin to fail

##### Release 1.23

* Fix textbox for argument is too short

##### Release 1.21

* Fix JENKINS-19830 - Masked Password visible as plain text in Msbuild Plugin

##### Release 1.20

* Fix JENKINS-19432 - Add option: "If warnings during msbuild, set the build to unstable"

##### Release 1.19

* Fix JENKINS-18543 - Update to newest MSBuild plugin breaks passing of release configurations with spaces in them

##### Release 1.18

* Fix JENKINS-17876 - MSBuild Command Line Arguments quotes being stripped...not 5552

##### Release 1.17

* Fix JENKINS-5552 - MSBuild plugin creates malformed command line

##### Release 1.16

* Fix JENKINS-14898 - MsBuild windows style environment variables no longer work
* Fix JENKINS-15029 - Update of MSBuild plugin to 1.15 causes Parameterized trigger plugin to fail.

##### Release 1.15

* Fix issue on backward compatibility

##### Release 1.14

* Fix JENKINS-13863 - MSBuild is unable to build projects in a different directory

##### Release 1.13

* Merge pull request - Add a checkbox to exclude a failure on msbuild step

##### Release 1.12

* Add UI checkbox to control build variables passing

##### Release 1.11

* Integrate pull request - Use lowercase "/p" for xbuild compatibility

##### Release 1.10

* Integrate pull request - Change Internal object: Descriptor by BuildStepDescriptor

##### Release 1.9

* Fix command generation with multiple build parameters

##### Release 1.8.2 (December 25, 2011)

* Fix JENKINS-12222 - java.lang.NullPointerException in the msbuild plugin when a job is executed by the parameterized build trigger plugin

##### Release 1.8.1 (December 03, 2011)

* Fix double quoted default args

##### Release 1.8 (December 01, 2011)

* Add default args (global configuration) - Merged pull request

##### Release 1.7 (May 13, 2011)
• Fix JENKINS-3823 - configure msbuild path as a tool
and JENKINS-4120 - Implement concept of tool installation into MSBuild plugin
##### Release 1.5 (May 05, 2011)
• Add variables (from build and environment) resolution.
##### Release 1.4 (April 02, 2011)
• Fix JENKINS-4121 - Existence check for MsBuild.exe does not account for non-master nodes
##### Release 1.3 (Dec 29, 2009)
• Add build parameters as properties (JENKINS-2349)
• Console output should show the command (JENKINS-3610)
• Update uses of deprecated APIs
##### Release 1.2 (Apr 21, 2009)
• Add a the possibility to manage multiple Msbuild version (JENKINS-3179)
##### Release 1.1 (Jun 03, 2008)
• Initial release

1. I have Hudson configured to use a slave node with .Net 3.5 for a job. That job requires .Net 3.5 and I've configured the MSBuild path in the Master's configuration, however on executing the job it fails because it can't find MSBuild. The master only has .Net 2 but I'd have thought that the check should be made by the slave. Any way around this other than installing .Net 3.5 on the master?

2. Same issue as Graeme's one on my installation: the plugin checks the MSBuild path on the master, not on the slave. I suppose this is a regression of version 1.2.

3. If you're having issues with MSBuild paths on slaves, see JENKINS-3632 for possible workarounds.

4. I have configured "MsBuild Build File" with path relative to Workspace folder "project\project.csproj". The real path is "C:\Program Files\.hudson\jobs\project\workspace\project\project.csproj" I receive "MSBUILD : error MSB1009: Project file does not exist." message during build. Build succeded if I set real path as "MsBuild Build File".

Is it possible to set relative path to project as "MsBuild Build File?

1. I'm seeing the same problem. The best solution I've found is to run a windows batch command that goes into the project directory and then run the msbuild task. You can also run a windows batch command to get the absolute path, run the job, and then use the absolute path for the msbuild task. I looked at the code it doesn't make sense that its doing this. Does anyone have a fix?

1. I just ran into this very same issue. I have my job polling a VSS database for the code, and I'm using the MSBuild plugin to do the build (which uses the local instance of the .NET installation). The job fails and I get the "Project file does not exist" error. I haven't tried the windows batch approach. I'm not sure if that would be feasible if I'm not checking-out the code from VSS. Any help would be greatly appreciated!

2. I worked around this by prefixing the path with %workspace%.

e.g.:

%workspace%\relative\path\to\project_or_solution

5. I have problems with parameterized builds. I would like to do an optional clean before the build. I've tried to define a parameter with the possible values "Build" or "Clean;Build". I was hoping to pass this value to the /target command line option. Unfortunately the parameters seem to be only passed as MSBuild parameters (i.e.: "/parameter:VAR_NAME=VAR_VALUE") and not as targets or environment variables which would be replaced by their values. Is there a way to get around this problem?

6. I have a jenkins (ver.1.399) installed on a redhat, and needed to integrate a .net project with it. So I setup a slave node and configure my project to use MSBuilder plugin (ver.1.3) to build my project on the slave, where a windows server is running.

When building the project through jenkins, it crashes. The following is viewed on the console:

Started by user anonymous
Building remotely on Slave
At revision 318
no change for https://svn.addresss/project since the previous build
FATAL: C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe doesn't exist
Finished: FAILURE

The path is right, MSBuild.exe is there.

What can be done to fix this problem? I searched on the web and found lot of people with the same problem, but no solution.

7. Is it possible to pass the build number or SCM revision number to MSBuild?

1. Fixed.

Variables resolution have been done in 1.5.

1. When will 1.5 be available?

8. One of the latest updates -- 1.5 or maybe 1.4 -- has broken a number of my builds.

I use the MSBuild plugin to build msbuild scripts named "﻿[foo].msbuild".  These scripts do a number of pre and post-build actions.

The plugin seems to not recognise the script file and I get a build failure along the lines of "Could not find .proj or .sln file".  In other cases, I think when the [foo] in foo.msbuild matches foo.sln, the solution file is built directly. This is no good as the prebuild actions aren't done.

One workaround I have found is to put an optional argument into the appropriate textbox, e.g. "/v:d" which turns on Debug verbosity.

I would like to be able to call any filename from the MSBuild plugin, as I would when using MSBuild.exe directly on the command line.

-- JENKINS-9643 raised --

1. Thanks for raising the issue.

9. I have a little problem with version 1.7

I have to use devenv.com (so visual studio) instead of msbuild because of msi projects in the solution I want to build and that msbuild cannot handle.

I also use parametrized build but not for this part of the build and parameters are passed to devenv.com in this form: -P:param1=value1, which make crash devenv.com:

Invalid Command Line. Unknown Switch : param1=value1

would it be possible to add a property in the project configuration not to take into account parameters?

thanks

1. It's possible to add an option
Please could you raise an enhancement in the issue trackker?

Additionally, could you give me a sample of the command line that Jenkins has to execute.

10. hi

I want add more  Project path  in a job  ,  to fix the problem  of reference,   how can i do ?

why the Team Foundation Server plugin do not have the Button like " add more locations "

the SVN plugin have this function.

1. You can define multiple MSBuild locations in the global configuration page. For each configuration, you give a logical name and a path value.
Then, you are able to choose a MSBuild location by its logical name in the Jenkins job.

11. There seem to be some problems with passing multiple parameters to MSBuild. It generates an invalid command line:

... ﻿/P:key1=value1 /P:key2=value2 ...

The appropriate syntax would be:

... ﻿/P:key1=value1;key2=value2 ...

I think the following line from /plugins/msbuild/MsBuildBuilder.java causes this problem:args.addKeyValuePairs("/P:", build.getBuildVariables());

1. Fix in 1.9

12. I'm using a free Jenkins instance on Amazon AWS from JenkinsHosting.com and have added the MSBuild plugin to build some Mono projects. It works if you give it the appropriate Mono command as its msbuild.exe path. I've built a number of versions of my projects with it, but it sometimes seems to have problems and hangs indefinitely in the msbuild section.

I've got Jenkins set up to poll my DVCS (Mercurial) every night and do the build. Normally, when I get up the next morning, the build has ended up hanging and the tail of the output is just:

Path To MSBuild.exe: /usr/bin/xbuild
Executing command: /usr/bin/xbuild IBBoard.csproj
[IBBoard] $/usr/bin/xbuild IBBoard.csproj XBuild Engine Version 2.6.7.0 Mono, Version 2.6.7.0 Copyright (C) Marek Sieradzki 2005-2008, Novell 2008-2009. Build started 01/31/2012 23:01:14. __________________________________________________ Project "/path/to/IBBoard/IBBoard.csproj" (default target(s)): Target _ValidateEssentialProperties: Target PrepareForBuild: Configuration: Debug Platform: AnyCPU Target GetFrameworkPaths: Target SplitProjectReferencesByExistent: Target ResolveProjectReferences: Target ResolveAssemblyReferences: Target CopyFilesMarkedCopyLocal: Target AssignTargetPaths: Target SplitResourcesByCulture: Target CreateManifestResourceNames: Target GenerateResources: Target GenerateSatelliteAssemblies: Skipping target "GenerateSatelliteAssemblies" because its outputs are up-to-date. Target CoreCompile: Tool /usr/bin/gmcs execution started with arguments: /noconfig /debug:full /delaysign- /debug+ /optimize- /out:obj/Debug/IBBoard.dll ...[list of .cs files]... /target:library /define:DEBUG;TRACE /reference:/usr/lib/mono/2.0/System.dll /reference:/usr/lib/mono/2.0/System.Xml.dll /warn:4 If I kill the job and start it manually then it works fine and I don't remember it failing. It only seems to be the time triggered builds that have problems. I only appear to be using v1.6 of the plugin (the latest that the instance has available) and I only have access to the web front-end (although I might be able to get the JenkinsHosting guys to do some stuff - they already added some of the Mono build bits and configured Mercurial). Thanks. 13. Hi, I have a project with several solutions wich i build with msbuild. The problem is if the first solution fails building the rest doesn't get built, and i can't get an actual error count on the project. I would like to continue my job even if an Msbuild step fails, is it possible to add an option to this? Thanks 1. Hi I've check'ed out your source code and developed this funcionality, if you want to add it, just email me. 1. Yes, could you submit a pull request? I'll look at it. 1. Pull REquest #5 - Add opt to continue job on msbuild failure 14. Hi everybody, I am building a .NET project on a Windows 7 (64b) Jenkins Slave. I keep getting an error in relation to a .pfx key file (not using ClickOnce): C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(1805,7): error MSB4018: The "ResolveKeySource" task failed unexpectedly.When I run the MSBuild step locally on the slave, I always get a Password dialog for the pfx file. I have tried installing the certificate as the Jenkins user on the Slave, but I still get the dialog. I was wondering if there is a parameter that I can use to send the pfx password with the build? Has anyone encountered this before, and found an elegant solution? One can always hope. 15. This is Philip From China, Today i try to use the Plug-In (MSBUILD.PlugIn) For First Time, And I have some doubt about this PlugIn Can use this PlugIn In Visual Studio .net 2003? I configured my MSBUILD Path is to : C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe here one more issue i am building a .NET 2003 project on a Windows XP SP2, ### show below :Building remotely on VM-BUILD1 Path To MSBuild.exe: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe Executing command: cmd.exe /C C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe C:\projects\Pixie\Client\CAgent\ClientAgent\Win\i386\ClientAgent.vcproj && exit %%ERRORLEVEL%% TestVMSlave$ cmd.exe /C C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe C:\projects\Pixie\Client\CAgent\ClientAgent\Win\i386\ClientAgent.vcproj && exit %%ERRORLEVEL%%
Microsoft (R) Build Engine Version 2.0.50727.3053
Microsoft .NET Framework, Version 2.0.50727.3082

Build started 09/05/2012 08:27:35.
__________________________________________________
Project "C:\projects\Pixie\Client\CAgent\ClientAgent\Win\i386\ClientAgent.vcproj" (default targets):

Target Build:
C:\projects\Pixie\Client\CAgent\ClientAgent\Win\i386\ClientAgent.vcproj : warning MSB4098: MSBuild is invoking VCBuild to build this project. Project-to-project references between VC++ projects (.VCPROJ) and C#/VB/VJ# projects (.CSPROJ, .VBPROJ, .VJSPROJ) are not supported by the command-line build systems when building stand-alone VC++ projects. Projects that contain such project-to-project references will fail to build. Please build the solution file containing this project instead.
C:\projects\Pixie\Client\CAgent\ClientAgent\Win\i386\ClientAgent.vcproj : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere.
Done building target "Build" in project "ClientAgent.vcproj" – FAILED.

Done building project "ClientAgent.vcproj" – FAILED.

Build FAILED.
C:\projects\Pixie\Client\CAgent\ClientAgent\Win\i386\ClientAgent.vcproj : warning MSB4098: MSBuild is invoking VCBuild to build this project. Project-to-project references between VC++ projects (.VCPROJ) and C#/VB/VJ# projects (.CSPROJ, .VBPROJ, .VJSPROJ) are not supported by the command-line build systems when building stand-alone VC++ projects. Projects that contain such project-to-project references will fail to build. Please build the solution file containing this project instead.
C:\projects\Pixie\Client\CAgent\ClientAgent\Win\i386\ClientAgent.vcproj : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere.
1 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.04
DEBUG Skipping watched dependency update for build: TestVMSlave #70 due to result: FAILURE
Finished: FAILURE
Have any people meet this issue, thanks?

1. Here's a crazy suggestion: why don't you read the error message, that is telling you exactly what the problem is and exactly what to do to fix it?

1. Sorry, Could you pls give your suggestion in detail ? thanks

16. I am getting following error:

Path To MSBuild.exe: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe
Executing command: cmd.exe /C C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe /t:Rebuild C:\TEMP\helloWorld\helloWorld.sln && exit %%ERRORLEVEL%%
test VS6 $cmd.exe /C C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe /t:Rebuild C:\TEMP\helloWorld\helloWorld.sln && exit %%ERRORLEVEL%% Microsoft (R) Build Engine Version 4.0.30319.1 Microsoft .NET Framework, Version 4.0.30319.269 Copyright (C) Microsoft Corporation 2007. All rights reserved. MSBUILD : error MSB1009: Project file does not exist. Switch: C:\TEMP\helloWorld\helloWorld.sln Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure Finished: FAILURE With user logged into the box and I can see the sln file, delete it, make a copy. I mean I have all access to the file. Not able to understand when job is kicked from Server, why it is not running. PS : I can copy the whole command and put on console and it builds. I am knocked out. If anyone have some idea. Please suggest where I am doing wrong. on the server it is configured to used Windows service and same user login credential are provided. 17. Can anyone tell what advantage of this pluging over simple invoking MSBuild from command line in a Batch Task Plugin? I've just installed this plugin and see the same results like when I build my Visual Studio projects from batch tasks before. Thanks! 1. This plugin is for now only an helper for building the msbuild command line. It is integrated in Jenkins by providing a form in the Jenkins configuration job. Moreover, it lets you define multiple MSBuild installation 1. Interestingly I had basically the same question. I was trying to encourage a colleague to use this plugin instead of using batch scripts built into the job but I couldn't work out any justification, other than I thought it's better to do it this way, to support my arguments. 18. ##### Release 1.18 This release has made working build getting failed with the following errorExecuting the command cmd.exe /C C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe /t:Clean /t:Build /p:Configuration=IPE "/p:Platform="Any CPU"" %WORKSPACE%\ADP.WFN.CAPayroll\ADP.WFN.CAPayroll.sln && exit %%ERRORLEVEL%% from C:\jenkins\jobs\PackageCAPayroll4.1HF35\workspace workspace$ cmd.exe /C C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe /t:Clean /t:Build /p:Configuration=IPE '/p:Platform="Any CPU"' %WORKSPACE%\ADP.WFN.CAPayroll\ADP.WFN.CAPayroll.sln && exit %%ERRORLEVEL%%
Microsoft (R) Build Engine Version 4.0.30319.1
Microsoft .NET Framework, Version 4.0.30319.296

MSBUILD : error MSB1008: Only one project can be specified.

For switch syntax, type "MSBuild /help"
Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure
Email was triggered for: Failure
Sending email for trigger: Failure

1. I'm getting the same exact issue with 1.18.  I had to rollback to 1.17, until this issue is fixed.

1. Does it OK with version 1.19?

19. hello !

i want to deploy an web project using jenkins ! but i m know how to do ﻿!

can you help me please ?

20. Hi

I am running Jenkins on a Linux master and I have Visual Studio Express 2010 (C++) installed on a Win 7 slave.  I can build my Visual Studio solution using MSBuild from the Visual Studio Command Prompt on the slave but when I try to do so using Jenkins I see error:

error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified.

Do I need to set-up the Visual Studio path within my Jenkins job?

David

21. **** VERY CRITICAL *****

When Pass build variables as properties is marked as true. Global password will be clearly visible in console output. It was found in version 1.20, it was not in version 1.16.

Please Fix this issue as soon as possible, as it is a security threat for us.

For reference attaching image. in which global declared password visible clearly with msbuild command.

but not visible when i echo in windows batch command.

22. To what web server i can deploy (.NET speaking) ??? Because i havent seen people deploying to IIS and i understand that IIS is the main web server for .NET.... Im new in this

23. VS2013's msbuild is in Program Files dir.  The spaces in the path breaks this plugin.

Workaround: include short path name to the exe in Jenkins configuration page.

This should be corrected.

Would also be a "nice to have" to allow selection of the msbuild version via a parameter, in jobs.

24. Well this board doesn't look to encouraging since the last post was almost a year ago and I see very few replies, but here goes:

Is there any way to get rid of the "/t:Rebuild" parameter Jenkins automatically adds on the command line?

The console output shows this

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe /nologo /t:Rebuild /t:MyTarget "myfile.msbuild"

The "/t:MyTarget" is a command line parameter I added in the build, but it get's ignored.

I'm running v1.2.4 of the plug in.

25. I am using this plugin

1. It builds website but, It is generating  *.compiled file

and my *.aspx  files are showing content  "This is a marker file generated by the precompilation tool, and should not be deleted!"

Need solution >> (I need *.aspx portion as it is , same as manual build)

2. My bin folder generates   "App_Web_ainm1mcf.dll"  like random name multiple dlls,

Need solution  >> (I need mywebsitename.dll  instead of multiple   "App_Web_ainm1mcf.dll"   dlls with random name)