Continuous Delivery using ASP.NET MVC4 – Web API

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

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”.

Following command line arguments need to be set exactly as 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 or whatever you want.

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

So let’s call the service and start deploying our branches!

Configure the HTTP Request Plugin.

Add a new build step named “HTTP Request”.


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 an 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 something on the Jenkins job configuration. To do so, 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.

Leave a reply

  1. Hi Santex,
    I downloaded the compressed file IISWebCreatorService.gz, which contains a file called IISWebCreatorService (without extension).
    Can you help me with the steps to install this component please?

    In the tutorial you point out is a windows service, Do I must install it using InstallUtil?

    Thanks in advance.

  2. Pingback: