Setup continuous integration for GitHub hosted .net project in Jenkins

In this tutorial, we will go through how you can setup an Automated build for your GitHub hosted .NET project in Jenkins each time you push new code.

If you don’t have Jenkins setup with IIS, you can do so by following my previous post.

For this tutorial, I am going to use my own GitHub hosted FakeRest project, but you can basically do the same for yours.


  • Jenkins hosted on a Windows server ( for MSBuild to work)
  • Git Plugin for Jenkins
  • Able to add Services under Integration & Services in Settings of GitHub hosted project. Basically a Hook.

Let’s start.

Install Git on the server

Go to: Git-Scm, download and install on the server.

Install Git Plugin for Jenkins

Go to Manage Jenkins -> Manage Plugin -> Available and search for “Git Plugin” and Install it.

Configure Git location in Jenkins

Go to Manage Jenkins -> Global Tool Configuration.

Under the Git section provided the git location from above installation. It should something like below:



You can also configure it to be installed Automatically.


Install MSBuild Plugin for Jenkins

Go to Manage Jenkins -> Manage Plugin -> Available and search for “MsBuild” and Install it. Wiki

Install MSBuild on your build server

Download “Build Tools for Visual Studio 2017” from

You can find it under “Other Tools and Framework”. Install it on the build server.

Once done, go to Manage Jenkins -> Global Tool Configuration and find “MSBuild” section and provide location path for msbuild.exe

It would be  “C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin”



Setup a new  FreeStyle Project in Jenkins

From Jenkins homepage create a new Item of type “FreeStyle Project”, provide a name and click OK.



On the next page, under “Source Code Management” choose “Git” and provide git project URL and credential.



Under the “Build Trigger” select “Poll SCM”, GitHub will use this setting to post information about a push to Jenkins. You can leave the schedule empty.



Setup Nuget restore

You will need to NuGet install on the server. With Visual Studio 2017 Nuget comes prepacked but on the build server, there is no Visual Studio so we have to download it. Download from: Nuget

Store the exe somewhere on the server.

Under the Build, section Add a new “Execute Windows batch command” Build Step. and set it up like shown in the screenshot below. Replace the location of nuget.exe with yours. Provide the name of the Solution. This will restore all the nuget packages your solution requires.



Next, Create a new build step of type “Build a visual studio project or solution using MSBuild”. Under the MSBuild version choose the one we added previously. Provide your Project file (NOT solution file) to build. And we will use “/P:Configuration=Release” as command line Arguments to create a release build.



And that’s it for Jenkins. Note, Order of the Build Step is important. Make sure Nuget Restore step is before actual Build step.

Create GitHub Hook (Service)

Go to your GitHub repository -> Settings -> Integrations & services.

Click “Add Service” and Choose Jenkins (Git Plugin) from the pop-up menu.



On the next step, provide you Jenkins Url and that’s it. Github and Jenkins take care of everything else.



Now, each time you push something, GitHub will trigger a new Jenkins build for the project setup.



a dev, an amateur photographer and a father


Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: