Jenkins Pipeline to deploy ASP .Net MVC Applications at SCM to local IIS Server

Abhishek Mallick
3 min readDec 20, 2019

--

In this post, we will talk about deploying any ASP .Net MVC Applications kept on a Source Code Management (SCM) to the local IIS server using Jenkins Pipeline.

Jenkins Pipeline to deploy ASP .Net MVC Applications at SCM to local IIS Server

Pre-requisite

· Jenkins

· ASP .Net Application

· Source Code Management tool (I am using GitLab for this post)

· IIS Server

PS: I will not be talking about setting up the above pre-requisite in this post so request you to google for the setup if you need any help.

Jenkins configurations for MS-Build

  1. MS-Build Plugin Installed
MS Build Plugin Installed in Jenkins

2. Global Configurations for MS-Build

The MS-Build path set in Jenkins Global Configurations

ASP .Net Application on GitLab

The Code in the GitLab with the Jenkinfile

Here you can see there is a file named “Jenkinsfile” which contains the script for the pipeline (will be talking about it further in this post)

IIS Server Default Website

Default Website on IIS

We will be using the “Default Web Site” on IIS to host our application.

Working on Jenkins Pipeline

1. Let us start by creating “New Item”

Step 1: New Item

2. Create a Pipeline by giving a name and selecting “Pipeline”

Entering New Item as Pipeline

3. Setting up the Pipeline to get the project from the SCM and running the script from the “Jenkinfile”

Setting up the Pipeline to work with SCM

4. Now once “Save” the pipeline is ready to “Build Now”

The Pipeline is ready to Build

The Build will complete and host the application on the IIS site name “Default Web Site”

Jenkinfile content

Detailing Jenkinfile

In this file, we have two steps named “stage”

  1. Source: This step gets the latest code from the SCM
  2. Build: This is the part which deals with the building and deployment of the code on the local IIS “Default Web Site” content folder “c:\inetpub\wwwroot”

More detail on the Build Stage

This below part of the code is running the MSBuild configured in Jenkins on the sln file

“\”${tool ‘MSBuild’}\” AspDotNetJenkins.sln

The below part is the paraments for the MS-Build that is to do the following:

/p:DeployOnBuild=true //Tell MS-Build to deploy on build
/p:DeployDefaultTarget=WebPublish //Use the WebPublish to Deploy
/p:WebPublishMethod=FileSystem //Use FileSystem for Publishing
/p:SkipInvalidConfigurations=true //Skip Invalid Configurations
/t:build //Do only the build
/p:Configuration=Release //Do the buld in release mode
/p:Platform=\”Any CPU\” //For any type of CPU
/p:DeleteExistingFiles=True //Empty the folder publishing the file
/p:publishUrl=c:\\inetpub\\wwwroot” //Publish at mentioned location

Check your deployed app

  1. Go to IIS and restart the website name “Default Web Site”
  2. Open your browser and go to http://localhost
The output from the local IIS

Please reach out if you need any further assistance.

--

--

Abhishek Mallick

Innovator, Visionary, Lead, Researcher and Creator. I work on multiple technologies with multi-level of complexity.