Is it possible to escape paths in pre-defined variables when using File Content Replacer (TeamCity 9.1)

Using TeamCity 9.1.3, I have a configuration that is using the file content replacer to specify the location of an object.

Specifically, I'm replacing ProjectReference elements with Reference elements in a VisualStudio C# project file (.csproj) and then using MSBuild to execute.

I'm inserting:

     <Reference Include="$1">

On the client, this gets expanded to:

     <Reference Include="Common">

It seems obvious that is expanded to "C:\BuildAgent\work\4405e151309223db" and the backslashes are being consumed in the substitution process (as escape sequences?).

Is it possible for me to escape the variable expansion? The obvious of putting it in quotes didn't help (as one would expect).

I have a work-around, but this would seem to be a general problem that is likely to come up again in the future or in other situtations where there may not be a work-around, so it would be really useful to know if there is a solution.

Comment actions Permalink

Hi Edward,

We have an issue in the tracker:, please vote for it. It's going to be fixed in TeamCity 10.0.
Sorry for the inconvenience.

Comment actions Permalink

Is this still an issue with TeamCity Enterprise 2017.2.2 (build 50909)?  I am currently running into the same issue using the File Content Replacer trying to replace my Find What value with "

If it is not fixed are there any recommended workarounds to keep me moving forward using this Build Feature?


Please sign in to leave a comment.