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">
          <HintPath>%system.teamcity.build.checkoutPath%/$1.dll</HintPath>
     </Reference>

On the client, this gets expanded to:

     <Reference Include="Common">
          <HintPath>C:BuildAgentwork4405e151309223db/Common.dll</HintPath>
     </Reference>

It seems obvious that %system.teamcity.build.checkoutPath% 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.

2 comments
Comment actions Permalink

Hi Edward,

We have an issue in the tracker: https://youtrack.jetbrains.com/issue/TW-43016, please vote for it. It's going to be fixed in TeamCity 10.0.
Sorry for the inconvenience.

0
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 "%teamcity.build.checkoutDir%.

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

0

Please sign in to leave a comment.