Jerusalem is the first qibla of Muslims and the capital of Palestine.

How to publish ASP.NET Core application by using Jenkins

26.03.2022 | min read

In this article, i will describe how to publish ASP.NET Core application by using Jenkins. Since the subject of the article is about preparing pipeline, you can benefit the link below for the installation of Jenkins.

How to Install Jenkins on Windows | BlazeMeter

Learn to install Jenkins with this easy guide. This tutorial will take you step by step to installing the Jenkins CI server on Windows. Start automating today.

Because the target machine on which we will make deployment in our scenerio and the machine in which Jenkins has been installed will be different , we need to arrange a dedicated server for Jenkins. The reason is that the Jobs could deplete your resources while they are working.

The pipeline is made of the following 4 steps.

Checkout: Pull the source code from the Github
Build: Build the source code
Deploy: Deployment to the target machine

Before preparing the pipeline, you need to fulfil the requirements below.

1. The installation of the Git

In order to get the checkout done, the Git need to be installed in the Jenkins machine. You can install the Git by using the address below.

Git - Downloading Package

You are downloading the latest (2.25.0) 32-bit version of Git for Windows. This is the most recent maintained build. It was released 8 days ago, on 2020-01-13.

2. The installation of NET Core SDK

To make the build, NET Core SDK need to be installed in the Jenkins machine. By using the address below, you can install the relevant SDK according to the version in your application.

Download .NET (Linux, macOS, and Windows)

Free downloads for building and running .NET apps on Linux, macOS, and Windows. Runtimes, SDKs, and developer packs for .NET Framework, .NET Core, and ASP.NET.

3. The installation of the MsDeploy in the Jenkins machine

To deployment, the msdeploy need to be installed in the Jenkins machine. For this, you can download the relevant installment from the address below.

Web Deploy 3.6 : The Official Microsoft IIS Site

Web Deploy (msdeploy) simplifies deployment of Web applications and Web sites to IIS servers. Administrators can use Web Deploy to synchronize IIS servers or to migrate to newer versions of IIS. We...

4. The introduction of the trusted machine

If the Jenkins machine and the target machine are not in the same domain, the deployment from the Jenkins machine to the target machine can't be done. There will be an error like below.

Connecting to remote server 0.0.0.0 failed with the following error message : The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting.

To solve the error, you need to indicate to Jenkins that the target machine is trusted. For this, you can apply the command line below in the Powershell.

    winrm set winrm/config/client '@{TrustedHosts="0.0.0.0"}'

5. The installation of the Web Management Service

To deployment remotely to the target machine, Web Management Service need to be installed and to be running in the IIS. Open the IIS to check whether the service has been installed. Choose your server from the connections window on the left. Check the Management Service module on the right section below the Management tab.

IIS - Management Service
IIS - Management Service

If the module does not appear, you can install the Management Tools from the Windows features.

6. The activation of the Web Management Service

The module need to be in a running state. You can activate the option "Enable Remote Connections" by double clicking the module, and make start.

IIS - Management Service 2
IIS - Management Service 2

7. The installation of the Msdeploy in the target machine

The MsDeploy need to be installed in the target machine. For this, you can download the relevant installment from the address below, and install it.

Web Deploy 3.6 : The Official Microsoft IIS Site

Web Deploy (msdeploy) simplifies deployment of Web applications and Web sites to IIS servers. Administrators can use Web Deploy to synchronize IIS servers or to migrate to newer versions of IIS. We...

Within the process of installation, you need to activate the "IIS Deployment Handler" feature by choosing the "Custom" option.

MsDeploy
MsDeploy

Open the IIS to check whether the service has been installed successfully. Choose your server from the connections window on the left. Check the Management Service Delegation module which is on the right and below the Management tab.

IIS Management Service Delegation
IIS Management Service Delegation

Everything is ready. Right now we can prepare the pipeline in the Jenkins.

Open Jenkins, follow the way "New Item > Pipeline" and create "job".

Jenkins - New Item
Jenkins - New Item

Paste the script below to the Pipeline section.

We are done. From now on you can make "Build Now". Good luck…

Share This Post

Leave a comment

Reply to

Cancel reply
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Your comment has been sent successfully reCaptcha couldn't be verified
Made with ASP.NET Core