Since TeamCity 2017.1, File Content Replacer can run in the fixed strings mode (similar to that of grep -F
), as opposed to the original regex mode:

If you use versioned settings (either XML or Kotlin DSL variant), there's yet another mode available to you (in addition to REGEX
and FIXED_STRINGS
): REGEX_MIXED
. In this mode, the search pattern will still be interpreted as a regular expression, but the replacement text will be quoted so that \
and $
characters will no longer have any special meaning.
If you export your settings to Kotlin, sample File Content Replacer configuration might look like:
features {
replaceContent {
fileRules = "**/*"
pattern = "(?iu)the\h+pattern\h+to\h+search\h+for"
regexMode = FileContentReplacer.RegexMode.REGEX_MIXED
replacement = """%teamcity.agent.work.dir%\nd_r\bin\isf"""
}
}