DEV Community

loading...

How to publish ASP.NET Core application by using Jenkins

ahmetkucukoglu profile image Ahmet Küçükoğlu Originally published at ahmetkucukoglu.com ・3 min read

This article was originally published at: https://www.ahmetkucukoglu.com/en/how-to-publish-asp-net-core-application-by-using-jenkins/

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

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

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)

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

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

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

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

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

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

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

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

Paste the script below to the Pipeline section.

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

Discussion

pic
Editor guide