Skip to content

Build Script Project for Building & Deploying .Net Solution Using Jenkin, MSBuild and PowerShell Script

Notifications You must be signed in to change notification settings

eathanspark/JenkinSetup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jenkins Build Script Project for Building & Deploying .Net Solution Using MSBuild and Power Shell Script

I have gone through internet to find a concrete solution to build and deployment a enterprise level .net solution using Jenkins. I found lots of article that say create a Jenkins job chose project type define build type deployment steps etc. But I am not satisfied with articles because it is not common practice, single .net solution can have multiple project of different kind like library, web application, utility, windows service , database project and these need to build and deploy on different location. So maintaining lots of Jenkins jobs for different activity is a tedious task.

Then I found a article in Microsoft Documentation website for creating a build script project there we can define multiple targets having multiple steps and in each steps/target we can execute windows command or power shell script and easily we can modify as per our requirement.

So Let's begin....

Main objective of this article is to create a build script project that will use in one of the Jenkins job to build & deploy a .Net Solution having different kind of projects let say one is .Net core with angular application and second one is a windows service. We will deploy .Net Core application on IIS and win service application on already install service.

Prerequisites:

Minimum hardware requirements:

  • 256 MB of RAM
  • 1 GB of drive space

Software requirements:

  • Java
  • Web browser

Download Jenkins

Go to https://www.jenkins.io/download/ and download stable windows installer

Installation steps

Go to download folder and double click on jenkins.msi and follow the steps below

Once installation is completed, Open web browser and type http://localhost:8080/ in address bar, you will see screen like below.. then wait for a while it will ask for first time login password .

Go to the password file location as below copy password and click continue.

C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins.jenkins\secrets\initialAdminPassword

Skip Plugin Installation for now and create first admin user.

Go to Dashboard click on Manage Jenkins then click on Manage Plugins it will redirect to plugins installation page like below

Here you might find the error in red color even if you will navigate to the available tab there also you will find the same error, so to solve this issue you have two options

  1. Install an SSL Certificate for connecting to Jenkins a secure service (SSL/TLS).

  2. Another quick way is to simply update site from https to http. Choose Manage Jenkins->Plugin Manager->Advanced

You will see the following update site default:

https://updates.jenkins-ci.org/update-center.json

Now change it to 

http://updates.jenkins-ci.org/update-center.json

You are done!

Now If you click on Available Tab you will found the different types of plugins available like below

MSBuild & Git Plugins installation

Set JDK Path

Go to the Dashboard and click on Manage jenkins then Click on Global Tool Configuration

In JDK section click Add JDK, Add jdk home path details whatever version install on your machine like below and click Save

Search MSBuild & Git plugin, Check both checkbox and click on Install without restart

I have created one sample .Net Solution "DotNetSampleProjectSolution" having two project for build & deployment.

Project 1: CoreSampleWebApplication(.NET Core + Angular)

Deploy Location: http://localhost:9090/

Physical Location: F:\JenkinsDeployment\IIS\CoreSampleWebApplication

Git Location: **https://github.com/eathanspark/JenkinSetup/tree/master/DotNetSampleProjectSolution/CoreSampleWebApplication

Project 2: WinServiceDemo (.NET Core Windows Service)

Physical Location: F:\JenkinsDeployment\WindowsService\WinServiceDemo\bin

Git Location: **https://github.com/eathanspark/JenkinSetup/tree/master/DotNetSampleProjectSolution/WinServiceDemo

Note : My jenkins server (hhtp://localhost:8080) and deployment server both are on same machine so it is litile bit confusing now but belive me it will be more cleare as progress in the blog.