![CD-Implementation-with-Jenkins]()
Introduction
When we build applications using ASP.NET Core for backend and Angular for frontend, we often deploy them manually copying files, publishing from Visual Studio, restarting IIS, etc.
It works fine for small projects, but as your team grows, manual deployment becomes risky one small mistake can cause downtime or overwrite settings.
That’s where CI/CD (Continuous Integration and Continuous Deployment) with Jenkins helps.
It automatically builds, tests, and deploys your project whenever you push code — safely and quickly.
In this post, I’ll show you step-by-step how I deploy a full-stack app (Angular + ASP.NET Core) using Jenkins pipeline on a Windows Server (IIS).
Requirements
Before we start, make sure you have:
Installed Jenkins (Windows or Linux)
Installed .NET SDK (e.g. .NET 8.0) on the Jenkins server
Installed Node.js and Angular CLI
Installed Git (for source code checkout)
Access to your IIS server for deployment
Project Structure
Below is a common folder structure we’ll work with:
RajeshDemoApp/
├── WebAPI/ # ASP.NET Core Backend
├── ClientApp/ # Angular Frontend
├── Jenkinsfile # Jenkins pipeline script
├── deploy.ps1 # PowerShell script for IIS deployment
Step 1. Create a Jenkins Pipeline Job
Open Jenkins Dashboard → New Item → Pipeline
Give it a name, e.g., RajeshDemoApp-CI-CD
Under Pipeline definition, select Pipeline script from SCM
Choose Git, and provide your repo URL.
Jenkins will now read the Jenkinsfile
from your repository.
![Step 1]()
Step 2. Jenkinsfile Configuration
Here’s a simple Jenkinsfile example for our project:
pipeline {
agent any
stages {
stage('Checkout Code') {
steps {
git branch: 'main', url: 'https://github.com/your-repo/RajeshDemoApp.git'
}
}
stage('Build Angular') {
steps {
dir('ClientApp') {
bat 'npm install'
bat 'ng build --configuration production'
}
}
}
stage('Build .NET Core') {
steps {
dir('WebAPI') {
bat 'dotnet restore'
bat 'dotnet publish -c Release -r win-x64 -o ../publish'
}
}
}
stage('Deploy to IIS') {
steps {
bat 'powershell .\\deploy.ps1'
}
}
}
}
Note:
If you’re using Linux agents, replace bat
with sh
.
Step 3. Create PowerShell Script for Deployment
Let’s create a PowerShell file named deploy.ps1
at the root of your repo.
This script will:
Stop IIS site
Backup old files
Copy new build files
Restart IIS site
Write-Host "Starting deployment..."
$source = "C:\Jenkins\workspace\MyApp-CI-CD\publish"
$destination = "C:\inetpub\wwwroot\RajeshDemoApp"
$backup = "C:\Backup\MyApp_" + (Get-Date -Format "yyyyMMdd_HHmmss")
# Stop IIS
iisreset /stop
# Backup existing site
if (Test-Path $destination) {
Copy-Item $destination $backup -Recurse
Write-Host "Backup created at $backup"
}
# Copy new files
Copy-Item $source\* $destination -Recurse -Force
# Start IIS
iisreset /start
Write-Host "Deployment completed successfully."
Step 4. Handle Configuration Files
We usually have environment-specific files like:
You can use a small PowerShell snippet to replace these files based on environment before publishing.
Example:
Copy-Item ".\Configs\Production\appsettings.json" ".\WebAPI\appsettings.json" -Force
Step 5. Run the Pipeline
Commit and push your code (including Jenkinsfile).
Go to Jenkins → click Build Now.
Jenkins will run each stage — build Angular, build .NET, deploy to IIS.
Step 6. Troubleshooting Tips
If deployment fails:
Check Jenkins console logs (very helpful).
Make sure IIS user has write permission to your deployment folder.
Ensure Node.js, Angular CLI, and .NET SDK paths are configured in Jenkins.
Step 7. Benefits of Using CI/CD
After setting this up once, your deployments become:
Automatic – no manual file copying
Consistent – same steps every time
Fast – 1-click deployment from Jenkins
Safe – automatic backup and rollback
Conclusion
By combining Jenkins, ASP.NET Core, and Angular, we can automate our entire deployment process.
No more “it works on my machine” issues — your build, test, and deployment happen exactly the same way every time.
You can extend this by adding:
Email notifications after successful builds
Deployment to QA, Staging, and Production
Integration with tools like SonarQube or Docker