TeamCity's File content replacer not reading regex input


I am using TeamCity by Jetbrains for some Continuous Integration. I am trying to change the Assembly file version number in a visual studio 2019 project using TeamCity's File Content Replacer. I selected .Net Core Assembly file version from the templates, which gave me (<(FileVersion)\s*>).*(<\/\s*\2\s*>). I put **/*.csproj in the "Process Files" and <FileVersion>%build.number%</FileVersion> in "Replace with".

This is the error I get in the TeamCity build log:

Applying replacement "" to lines matched by pattern "(<(FileVersion)\s*>).(</\s\2\s*>)" in the files matched by wildcard: **/*.csproj... Total files changed: 0. No modifications were made: either no text matching the pattern was found or the replaced text is the same as the original

Using **/*.csproj detects a wildcard, because changing it has netted in pure failure. I tested the regex in and it detected what I needed in the file. This is the layout in the project file:


<Project Sdk="Microsoft.NET.Sdk.Web">


  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

    <None Include="SetVersion.proj">

    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.12.0" />
    <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
    <PackageReference Include="MSBuild.Extension.Pack" Version="1.9.1" />
 Run code snippet


When I put this into the tester, the regex can detect the FileVersion line. Is there an issue with my regex? Or is my file path wrong?

1 comment
Comment actions Permalink

Could you show a screenshot of the exact setup of your file content replacer? I've copied and pasted your snippet into a file, added what you described to be your configuration, and the file content replacer worked just fine.


Please sign in to leave a comment.