Click here to Skip to main content
14,032,238 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


43 bookmarked
Posted 19 Feb 2015
Licenced CPOL

Integrate Jenkins with MSBuild and NuGet

, 28 Jan 2016
Rate this:
Please Sign up or sign in to vote.
The next logical step in your build will be to build your solution or projects. I will guide you how to do it via MSBuild as build engine and NuGet for downloading the necessary packages.

In my previous article, “Getting Started with Jenkins and GitHub”, I showed you how to create your first Jenkins job and download the source of your project from GitHub. If your projects are stored in TFS, you can read how to setup your Jenkins job for TFS here: “Integrate Jenkins with Team Foundation Server“. The next logical step in your build will be to build your solution or projects. I will guide you how to do it via MSBuild as build engine and NuGet for downloading the necessary packages.

Install Jenkins Plugins

  • Click Manage Jenkins link:

  • Click Manage Plugins link:

  • Click the Available tab and type the name of the desired plugin in the filter text box:

  • Install the MSBuild Plug-in – This plugin makes it possible to build a Visual Studio project (.proj) and solution files (.sln).

Configure Build Step

  • Open Manage Jenkins Page.
  • Click Configure System link.

  • Under the MSBuild section, click MSBuild Installations… button
  • Enter Name- msbuild.exe
  • Enter default path to msbuild.exe - C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MsBuild

  • Open the configure page of your Jenkins job
  • Click Add build step button
  • Select Build a Visual Studio project or solution using MSBuild
  • For MSBuild Version, choose the configuration that you have created – msbuild.exe
  • For MSBuild Build File – enter the path to the project/solution that needs to be built in the format - ${WORKSPACE}\PhantomTube\PhantomTube.sln (${WORKSPACE} is a Jenkins variable that contains the default workspace location)
  • In Command Line Arguments – you can enter msbuild.exe arguments that you use when you build your project though command line. For example /p:Configuration=Release is going to build your project in Release mode. Or you can increase the logging verbosity, etc.

Configure NuGet Package Restoration

In order to restore NuGet packages, you have a couple of options. You can try some of the available plugins. However, my preferred approach is to use Windows batch command.

First, you need to download the NuGet.exe which you are going to use for the operation. 

You need to paste a command like the following in the Command text box: “C:\J\Nuget\NuGet_2.81.exe restore “C:\J\jobs\PhantomTube\workspace\PhantomTube\PhantomTube.sln“”.

The step should be moved above the MSBuild step because in order for the build to be successful, you are going to need all package downloaded beforehand.

Now you are ready to test your setup. Open your job from the link listed on the main Jenkins page. Click the Build Now button.

If you open the console output, you can check the status of your build.

So Far in the Jenkins Series

  1. Integrate Jenkins with Team Foundation Server
  2. Integrate Jenkins and GitHub
  3. Configure Jenkins MSTest Tests Execution
  4. Delete TFS Workspace in Jenkins Job
  5. Output MSTest Tests Logs To Jenkins Console Log
  6. Integrate Jenkins with MSBuild and NuGet
  7. Create Jenkins Job for Creating NuGet Packages
  8. Visual Studio Test Agents Cleaning Scripts
  9. Jenkins Get Source Code By Specific TFS Changeset


If you enjoy my publications, feel free to <a href="" target="_blank">SUBSCRIBE</a>
Also, hit these share buttons. Thank you!


The post - Integrate Jenkins with MSBuild and NuGet appeared first on Automate The Planet.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Anton Angelov
CEO Automate The Planet
Bulgaria Bulgaria
Anton Angelov is an IT Consultant and Quality Assurance Architect at Innovative Lab. He is passionate about automation testing and designing test harness and tools, having the best industry development practices in mind. In addition, he is an active blogger and the founder of Automate The Planet. He strives to make the site one of the leading authorities in Automation Testing by presenting compelling articles, inspiring ardent discussions amongst the community. He is also one of the most-rated-answer authors of questions about Test Automation Frameworks (WebDriver) on Stack Overflow.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
yrsk.aravind13-Dec-18 19:29
memberyrsk.aravind13-Dec-18 19:29 
QuestionHi, I am facing issue in my jenkins buils can you please me out....! Pin
Member 1227015118-Jan-18 7:31
memberMember 1227015118-Jan-18 7:31 
QuestionNuget From a Batch? Your Favorite. How does this update .csproj Hintpaths? Pin
MarkWardell6-Oct-17 4:42
memberMarkWardell6-Oct-17 4:42 
PraiseThanks Pin
nishantk2319-Oct-16 2:04
membernishantk2319-Oct-16 2:04 
QuestionNice article Pin
Gandalf_TheWhite7-Oct-16 23:43
professionalGandalf_TheWhite7-Oct-16 23:43 
Questionmsbuild section missing after install Pin
Peter Andrews3-May-16 9:32
memberPeter Andrews3-May-16 9:32 
AnswerRe: msbuild section missing after install Pin
Anton Angelov9-May-16 7:56
memberAnton Angelov9-May-16 7:56 
GeneralRe: msbuild section missing after install Pin
Member 1370145328-Feb-18 2:36
memberMember 1370145328-Feb-18 2:36 
GeneralMy vote of 5 Pin
Santhakumar M28-Jan-16 19:15
professionalSanthakumar M28-Jan-16 19:15 
QuestionNuget Command Line Pin
Larry E27-Jan-16 7:31
memberLarry E27-Jan-16 7:31 
AnswerRe: Nuget Command Line Pin
Anton Angelov28-Jan-16 9:32
memberAnton Angelov28-Jan-16 9:32 
QuestionAre you sure that "the newest versions don’t support the restore command"? Pin
scatp12-Jan-16 9:37
memberscatp12-Jan-16 9:37 
GeneralMy vote of 5 Pin
Atanas Atanasov23-Feb-15 11:24
memberAtanas Atanasov23-Feb-15 11:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.190419.4 | Last Updated 28 Jan 2016
Article Copyright 2015 by Anton Angelov
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid