logo
search
Others

How to Build and Deploy Only Changed Files in Azure DevOps

John WilsonJohn Wilson Sep 28, 2026 869 views

Question details

The user needs to configure an Azure DevOps pipeline to build and deploy only modified artifacts to save time and reduce unnecessary processing.

How to Build and Deploy Only Changed Files in Azure DevOps
Product
Azure DevOps
Device & OS
not provided
Scenario
Optimizing a CI/CD pipeline for faster execution and deployment.
Observed behavior
The pipeline needs to implement incremental builds and correctly handle dependencies, renamed files, and deleted files during deployment.
Before you start

Ensure you have active Azure DevOps project administrator permissions and a working baseline pipeline before modifying your build and deployment processes.

Solution 1Recommended

Implement Incremental Builds and Custom Deployment Scripts

Utilize your build tool's incremental build capabilities alongside a script or specific deployment task that compares and transfers only modified files to the target environment.

To successfully deploy only changed files, you must first ensure that your build process only compiles modified source code. Afterward, a deployment tool or custom script is required to compare the newly built artifacts against the currently deployed files.

1
Enable Incremental Builds

In your Azure DevOps build pipeline, configure your build task (such as MSBuild) to support incremental builds. Ensure that the 'Clean' option in your repository settings is disabled so previous build outputs are retained.

2
Publish Artifacts

Add a 'Publish Build Artifacts' task to your pipeline to save the output of the incremental build, making it available for the release pipeline.

3
Compare and Deploy

In your release pipeline, use a specialized deployment task (like Azure App Service Deploy with 'Zip Deploy') or write a custom PowerShell/Bash script to compare file hashes or timestamps and copy only the updated files.

4
Handle Deletions and Dependencies

Update your deployment script to detect files that exist in the target deployment but are missing in the new build artifact, and safely remove them to maintain application consistency.

Implement Incremental Builds and Custom Deployment Scripts
Testing Required: Always test your incremental deployment process in a staging environment first to ensure that deleted files and complex dependencies are handled without breaking the application.
Free Microsoft Office alternative

Streamline Project Documentation with WPS Office

While you manage complex CI/CD pipelines in Azure DevOps, you need reliable tools for writing technical documentation. WPS Office provides a free, lightweight, and highly compatible alternative to Microsoft Office for all your project management needs.

Fully compatible with Microsoft Office formats like .docx, .xlsx, and .pptx.Lightweight and fast, consuming minimal system resources.Free to use for drafting deployment strategies, release notes, and architecture plans.
microsoft office alternative - wps office

Frequently Asked Questions

Does Azure DevOps have a built-in task to deploy only changed files?

While Azure DevOps itself orchestrates the pipeline, specific tasks like 'Azure App Service Deploy' offer features like 'Zip Deploy' which can update only changed files. For custom environments or VMs, you will likely need to implement your own script.

Why is my MSBuild recompiling all files instead of just changed ones?

This usually happens if the Azure DevOps agent is set to clean the workspace before each build. Ensure that 'Clean' is set to 'false' under the 'Get sources' step in your pipeline.

How can I synchronize deleted files during a deployment?

You can use tools like Web Deploy (msdeploy) with the '-enableRule:DoNotDeleteRule' removed, or use Robocopy with the '/MIR' (mirror) flag in your custom scripts to ensure deleted source files are removed from the destination.