These are instructions on how to set up and use the MSBuild plugin for jenkins.
Adding MSBuild settings
- Go to the jenkins Global Tool Configuration and scroll to find the MSBuild section.
- Click "MSBuild Installations..." then "Add MSBuild", now you should see 3 fields to fill in.
- Name: Your identifier for these settings, this can be whatever you like but I suggest describing the settings e.g. "vs2019 Release settings"
- Path to MSBuild: The path to the Visual Studio compiler.
Gotcha: In my experience to use the visual studio 2015 compiler I had to include the compiler in the path otherwise the plugin complains about not finding the compiler. Jenkins shows a warning when you do this but it works. - For Visual Studio 2015 use MSBuild 14 at:
C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe - For Visual Studio 2017 use MSBuild 15 at:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin - For Visual Studio 2019 use MSBuild 16 at:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin - Default parameters: Write here what parameters you wish to give the compiler.
e.g.: -t:Clean,Build -p:Configuration="Release" -p:Platform="x64"
MSBuild 16 uses hyphens for parameters but MSBuild 14 and 15 use a forward slash instead "/t:Clean,Build /p:Configuration="Release" /p:Platform="x64""
If you're unsure open a command prompt and run MSBuild.exe --help or MSBuild.exe /help - Click Save
Adding MSBuild to a job
- Go to the job configuration and scroll to find the Build section
- Click Add build step and choose "Build a Visual Studio project or solution using MSBuild"
- In the MSBuild Version list select the setting you saved earlier.
- In the MSBuild Build File enter the path for the solution
e.g. "$WORKSPACE\Builds\VisualStudio2019\MyProject.sln"
(Conviently, you can use the jenkins environment variables here) - Optional Additional parameters may be added to Command Line Arguments text box.
- Click Save