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
Please enter at least three characters to search
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

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Jenkins in the Age of Kubernetes: Strengths, Weaknesses, and Its Future in CI/CD
  • DORA Metrics: Tracking and Observability With Jenkins, Prometheus, and Observe
  • An Explanation of Jenkins Architecture
  • Implementing CI/CD Pipelines With Jenkins and Docker

Trending

  • Vibe Coding With GitHub Copilot: Optimizing API Performance in Fintech Microservices
  • A Modern Stack for Building Scalable Systems
  • Unmasking Entity-Based Data Masking: Best Practices 2025
  • Agile and Quality Engineering: A Holistic Perspective
  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
Likes (2)
Comment
Save
Tweet
Share
40.0K 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

  • Jenkins in the Age of Kubernetes: Strengths, Weaknesses, and Its Future in CI/CD
  • DORA Metrics: Tracking and Observability With Jenkins, Prometheus, and Observe
  • An Explanation of Jenkins Architecture
  • Implementing CI/CD Pipelines With Jenkins and Docker

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and 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:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!