DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Enterprise AI Trend Report: Gain insights on ethical AI, MLOps, generative AI, large language models, and much more.

2024 Cloud survey: Share your insights on microservices, containers, K8s, CI/CD, and DevOps (+ enter a $750 raffle!) for our Trend Reports.

PostgreSQL: Learn about the open-source RDBMS' advanced capabilities, core components, common commands and functions, and general DBA tasks.

AI Automation Essentials. Check out the latest Refcard on all things AI automation, including model training, data security, and more.

Related

  • Using Jenkins Local Maven Repository as An Internal Private Maven Repository
  • An Explanation of Jenkins Architecture
  • Implementing CI/CD Pipelines With Jenkins and Docker
  • Getting Started With Jenkins

Trending

  • Elevate Your Terminal Game: Hacks for a Productive Workspace
  • Enhancing Performance With Amazon Elasticache Redis: In-Depth Insights Into Cluster and Non-Cluster Modes
  • Understanding Kernel Monitoring in Windows and Linux
  • Automated Data Extraction Using ChatGPT AI: Benefits, Examples
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. DevOps and CI/CD
  4. CI/CD for .NET MVC Using Jenkins

CI/CD for .NET MVC Using Jenkins

In this tutorial, take a look at how Windows Visual Studio and Jenkins come together to create an effective CI/CD process for .NET applications.

By 
Shivangi Garg user avatar
Shivangi Garg
·
Manoj Debnath user avatar
Manoj Debnath
·
Updated Feb. 06, 24 · Tutorial
Like (2)
Save
Tweet
Share
35.8K Views

Join the DZone community and get the full member experience.

Join For Free

Jenkins is an open-source, self-contained automation server that includes the features of continuous integration (CI), continuous delivery, and deployment (CD) pipelines. Continuous integration ensures that team members commit their work on a regular basis so that build can be conducted upon significant change. The CI generates a continuous feedback loop of the software and any defect or deficiencies identified are resolved early and easily. Continuous delivery (CD), on the other hand, automates the process of build, test, and deployment operations. In both cases, the Jenkins server states that the best practices are followed and the desired state is achieved. Since the process is automated Jenkins helps in increasing the pace of release. This eradicates limitation of the manual deployment and reduces the stress on the development and operation team significantly.

Jenkins provides many ways to set up a CI/CD environment for almost any code language and source code repository. It has a suite of plugins to implement CI/CD pipelines in .NET MVC application development and ensure high-quality deliverables. These plugins can be extended to support MSBuild files, Git version control, CVS, Subversion, etc. Once the MSBuild plugin is installed and configured, the Jenkins pipeline is initiated. The automation server takes care of almost the entire development life cycle starting from integration and testing to the deployment of the the .NET MVC application development. The DevOps team can focus on the product, update, and new features while many intricate processes are handled behind the scenes by the Jenkins server. For more details about automation servers, review our coverage of Jenkins vs. Bamboo.

The article provides a basic step-by-step implementation of CI/CD for the .NET MVC framework using Jenkins.

Step 1: Installing Build Tools Through Visual Studio Installer

Before we proceed with actual building and deployment, we need to make sure we have build tools installed on the machine.

This can be done through Visual Studio Build Tools, available from the Visual Studio Installer. 

Visual Studio Installer


Then we need to install build tools to build an MVC application. This can be done by clicking the Modify button for Visual Studio Build Tools and then selecting Web development build tools.

Web development build tools


If we didn't install these build tools, the msbuild  command would only work in the Developer Command Prompt.

Step 2: Installing Plugins for Jenkins

We need to install plugins to use in Jenkins.

  1. Go to Manage Plugins.
  2. Find and install the GitHub Plugin.
  3. Find and install the MSBuild Plugin.

I have implemented CI/CD using Jenkins. First of all, you need to download Jenkins. There are a number of ways to use it. I am using it as a Windows service on the machine. After starting the Jenkins service, you need to add your application and the configuration. First, click on "New Item." Then, give the application an Item Name, select the "Freestyle Project" option, and then click "OK."

Jenkins: Enter an item name


Step 3: The Configuration

Now for the configuration.

In the General section, you can enter the description of the item and discard the old builds. It will automatically discard builds.

In the Source Code section, I used a Git repository. Here we have to provide the URL of the repository and the branch name from which you want to deploy the code.

Source code management section


Build triggers selections


In the build environment, we want to make sure we choose to clean the Jenkins workspace before the build starts.

Build environment selections


Step 4: Restoring NuGet Packages

When we commit the code in the repository, we don't commit the packages, so first we have to restore the NuGet packages.

As you can see, the code is committed without NuGet dependencies.

Code is committed without NuGet dependencies


restore command


Execute Windows batch command screen


Once the command is entered, you can see the packages folder created with all NuGet dependencies.

List of packages folder showing NuGet dependencies


Step 5: Using MSBuild

Now we can actually execute the MSBuild command.

This command requires that the MSBuild plugin be installed in Jenkins, the path to the sln file, and optionally, we can also provide the PackageFileName  attribute in the command line with the path and package name.

Build a Visual Studio project or solution using MSBuild screen


Command:

 
/t:clean;build;package /p:PackageFileName="C:\Program Files (x86)\Jenkins\workspace\HelpDesk_CI\HelpdeskMVC.zip"


Step 6: Using MSDeploy Command

MSDeploy command can be used to deploy the zip created in the previous step to be deployed to IIS.

MSDeploy command


Command:

 
C:\"Program Files (x86)"\IIS\"Microsoft Web Deploy V3"\msdeploy.exe -verb:sync -source:package="HelpdeskMVC.zip" -dest:auto -setParam:name="IIS Web Application Name",value="Default Web Site/Helpdesk"


Step 7: Install Web Deployment Tool

In order to deploy the zip, you need to install "Web Deployment Tool 2.1".

You can install this by right-clicking on "Default Web Site" and then going to "Install Application from Gallery".

Install Application From Gallery menu item


Then search for "Web Deployment Tool 2.1" in the search box. In my case, it is already installed.

Web Platform Installer: Web Deployment Tool 2.1 installed

Step 8: Post Build/Deploy Actions

You can add various post-build actions like sending email notifications, archiving the deployable artifact, etc.

Add post-build action dropdown menu


You have now created a very basic CI/CD for your .NET MVC application. Jenkins gives us flexibility for adding more complex builds.

Continuous Integration/Deployment Jenkins (software) NuGet Repository (version control) MSBuild

Opinions expressed by DZone contributors are their own.

Related

  • Using Jenkins Local Maven Repository as An Internal Private Maven Repository
  • An Explanation of Jenkins Architecture
  • Implementing CI/CD Pipelines With Jenkins and Docker
  • Getting Started With Jenkins

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: