Continuous Delivery using ASP.NET MVC4 – Web API

By Gastón Robledo, Architect at Santex

This post will help you learn how to create continuous delivery using ASP.NET MVC4, which is a web API.

Software Needed

  • Jenkins
  • MSBuild
  • Web Deployment Tool 3.5
  • IISWebSiteCreation (Custom Application)
  • MSTests
  • GIT
  • Jenkins MSBuild Plugin
  • HTTP Requests Plugin

Both environments, deployment target server, and CI server must have Web Deployment Tool 3.5 installed to them.

Jenkins Set Up

Step 1

Create a Jenkins job that will pull the code from a specific branch of code. To do this, you must set a String parameter to receive the branch name to build.

Step 2

Once Jenkins clones or pulls the code from that branch, we need to call MSBuild to actually build the code. In order to do this, Jenkins MSBuild Plugin must be installed and configured as a build step.

Add a new build step named “Build a Visual Studio project or solution using MSBuild.”

Jenkins tutorial - MSBuild Plugin configured as a build step

The following command line arguments need to be set exactly as they are outlined below:

/p:publishUrl is the destination folder where the build will be located, at this point you can choose any location.

Step 3

IISWebSiteCreation (.NET Framework  4.5 – Custom Component)

Download, build, and install the attached component into the deployment server.

IISWebSiteCreation is a windows service that I wrote in C# that allows you to create websites on IIS. This Windows service exposes a url so we can call it from Jenkins to create a website.

How to use the component:


sitename = The name of the branch in this case.

Parameters that can be set as default in the app.config file:

applicationPoolName: AppPoolName of IIS
tcpPort: Port where the website is listening requests.
ipAddress: If you have more than one IP to listen on IIS you can put here what you want. Default = ‘*’
hostHeader: Here you can put the header of the website like

Step 4

Let’s call the service and start deploying our branches!

Configure the HTTP Request Plugin.

Add a new build step named “HTTP Request.”

Jenkins tutorial - Add a new build step


Method: GET

Where $BRANCH_NAME is the branch code that we indicate to Jenkins to pull the code from, so that the service will create a site named on IIS pointing to a specific folder that will contain the built code, inside the main domain.

Step 5

Now, let’s call the Web Deploy command.

Create a build step name “Execute Command.”

Hint: It is best not to reveal the password or anything on the Jenkins job configuration. To avoid doing this, create a cmd file and put it on the Jenkins server. It’s up to you!


“C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe” -allowUntrusted -verb:sync -source:contentPath=”%WORKSPACE%\builds” -dest:contentPath=’C:\inetpub\wwwroot\\%BRANCH_NAME%


Once it finishes, you can go to http://[branch_name] in the deployment target server and you will see your code deployed!

I hope you enjoy it!

Download: IISWebCreatorService

Gaston Robledo is a versatile System Architect that specializes in enterprise software development and has more than 10 years of experience in the IT industry. Gastón started his career exclusively as .NET developer and over the years expanded to include a wide array of technologies (.NET, PHP, Java and Python). He adapts quickly and excels in almost any programming language. He enjoys collaborating with innovative teams and laterally thinking problems. Gastón always challenging himself to come up with an out-of-the-box solutions.

Don't forget to share this post!

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on whatsapp
Share on print