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 "1.0.0.112" 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 https://regex101.com/ and it detected what I needed in the file. This is the layout in the project file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<AssemblyVersion>1.0.0.1</AssemblyVersion>
<TargetFramework>netcoreapp3.1</TargetFramework>
<FileVersion>1.0.1.1</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<None Include="SetVersion.proj">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<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" />
</ItemGroup>
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?
Please sign in to leave a comment.
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.