Optimize CI/CD for Legacy Projects Without Docker or Proper CI/CD Configuration
- PowerShell - Documentation
- MSBuild - Documentation
- Azure DevOps & Pipelines - Documentation
- CI/CD - Documentation
This script optimizes CI/CD pipelines by building only the projects that have changed, instead of rebuilding the entire solution. It is especially useful for:
- Large solutions with 100+ projects
- Legacy projects without Docker or properly configured CI/CD
- Reducing build times in Azure DevOps Pipelines
- Save Time: ⏱️ Reduce build times by up to 20 minutes!
- Selective Builds: 🛠️ Build only the projects that have changed.
- Customizable: 🔧 Adaptable to your project structure.
- Legacy-Friendly: 🏛️ Works even without modern CI/CD tools like Docker.
- Detect Changes: Compares the current branch with the target branch to identify changed files.
- Filter Projects: Extracts the list of projects (
.csproj
) affected by the changes. - Set Variables: Passes the list of changed projects to MSBuild for selective building.
Building the entire solution, even for small changes.
Building only the changed projects.
- Clone the repository.
- Configure the script parameters:
CompareSourceBranch
BranchName
Repository
TargetBranch
- Run the script in your Azure DevOps pipeline.
Instead of building the entire solution (.sln
), pass the list of changed projects to MSBuild:
<Project>
<Target Name="Build">
<MSBuild Projects="$(projects)" />
</Target>
</Project>
If your deployment method allows copying only changed files/projects, this script will save you time and resources.
Don't build the whole solution—build only what has changed!