Azure DevOps Extensions Replace In Files
Azure DevOps Extensions are powerful add-ons that enable you to customize and extend your DevOps experience with both Azure DevOps Server (on-premises) and Azure DevOps Services (cloud-based). These extensions seamlessly integrate into your existing pipelines, repositories, boards, and test plans, providing additional functionality that addresses specific workflow requirements and automation needs beyond the platform's core capabilities.
Extensions bridge the gap between Azure DevOps' built-in features and your unique development processes. Whether you need specialized build tasks, custom release pipeline steps, enhanced work item tracking, dashboard widgets, or third-party service integrations, extensions provide the flexibility to adapt Azure DevOps to your exact requirements rather than forcing your processes to conform to default functionality.
These extensions are developed using standard, widely-adopted web technologies including HTML and CSS for markup and visual presentation, TypeScript for type-safe client-side logic and modern JavaScript development, and PowerShell for automation scripts, build tasks, and server-side operations. This accessibility means extensions can be created, maintained, and customized using familiar tools and languages that most development teams already possess, without requiring specialized or proprietary development environments.
Replace In Files Task
Replace In Files is a comprehensive extension containing two specialized tasks designed to replace text in source files during your Azure DevOps Build Pipeline, providing flexible text manipulation capabilities that adapt to different transformation scenarios.
In modern CI/CD workflows, there's frequently a need to modify values in source code before compilation or deployment. This might include updating configuration settings for different environments, injecting build-specific identifiers, modifying API endpoints, updating version strings embedded in code, or transforming placeholder values into actual deployment parameters. Rather than maintaining multiple versions of files or relying on manual editing, automated text replacement ensures consistency and eliminates human error from the deployment process.
This extension provides two distinct approaches to text replacement, each optimized for specific use cases and replacement patterns.
Replace In File Between Text
Replace In File Between Text provides pattern-based replacement by identifying and replacing content that appears between specified start and end markers in your source files.
This task is particularly powerful for scenarios where you need to replace entire blocks of content bounded by identifiable delimiters. For example, you might have configuration sections marked by comment blocks, code segments between specific tags, or data structures enclosed by markers. The task locates the start pattern, captures everything until it finds the end pattern, and replaces the entire section with your specified content.
This approach is ideal for replacing multi-line content blocks, updating entire configuration sections, transforming templated code segments, or modifying structured content where the boundaries are well-defined. By working with delimited sections rather than exact matches, it provides flexibility when the specific content between markers might vary but the markers themselves remain consistent.
Replace In File Text By Text
Replace In File Text By Text performs straightforward text substitution, replacing exact text matches in source files with specified replacement values.
This task handles the most common replacement scenario—finding specific strings and replacing them with new values. It supports both simple literal replacements and can work with multiple replacement operations across numerous files in a single task execution. The simplicity and directness of this approach makes it perfect for updating configuration values, replacing hardcoded strings with environment-specific values, modifying version identifiers, updating URLs or connection strings, and performing any scenario where you know exactly what text needs to change.
Both tasks integrate seamlessly into YAML or classic pipelines, support wildcard file selection to process multiple files efficiently, and execute during the build process before compilation—ensuring your source code is properly configured for the target environment before any downstream steps execute.
You can find a video of how to use this Nuget Package here.
For more details on how to install and configure this extension click here.