File Content Replacer, is is the build feature which processes text files by performing regular expression replacements before a build. After the build, it restores the file content to the original state.
...
You can specify the values manually or use value presets for replacement, which can be edited if needed.
Option | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
anchor Template | Template | Template (optional):
File Content Replacer provides a template for every attribute to be replaced. Clicking the Load Template... button displays the combobox with templates containing value presets for replacement. The templates can be filtered by language (e.g. | |||||||||||||||||||
Process files: |
Click Edit file list and specify paths to files where the values to be replaced will be searched. Provide a newline- or comma-separated set of rules in the form of +|-:[path relative to the checkout directory] . | ||||||||||||||||||||
File encoding: |
By default, TeamCity will auto-detect the file encoding. To specify the encoding explicitly, select it from the drop-down. When specifying a custom encoding, make sure it is supported by the agent. | ||||||||||||||||||||
Find what: |
Specify a pattern to search for, in the regular expression format. MULTILINE mode is on by default. | ||||||||||||||||||||
Match case: |
By default, the comparison is case-sensitive. Uncheck for case-insensitive languages. | ||||||||||||||||||||
Regex: |
| Replacement
| Replacement | Replace with:
Since TeamCity 2017.1 The box is checked by default and applies to both the search and replacement strings. Uncheck to use fixed strings.
| |||||||||||||||||
Replace with: |
Type the text to be used for replacing the characters in the Find what box. To delete the characters in the Find what box from your file, leave this box blank. $N sequence references N-th capturing group. All backslashes (\) and dollar signs ($) without a special meaning should be quoted (as \\ and \$, respectively).
|
Templates
Anchor | ||||
---|---|---|---|---|
|
Templates
This section lists the available replacement templates.
...
The templates for replacing the following Assembly attributes are provided (listed in see this section for comparison with AssemblyInfo Patcher): Wiki Markup
{table-plus:border=0|class=''|sortIcon=true}
|| Assembly attribute || Supported by _[TCD9:AssemblyInfo Patcher]_ || Supported by _File Content Replacer_ ||
|- [{{CLSCompliant}}|http://msdn.microsoft.com/en-us/library/system.clscompliantattribute.aspx] | No | C# only |
|- [{{ComVisible}} |http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comvisibleattribute.aspx] | No | C# only |
|- [{{Guid}}|http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.guidattribute.aspx] | No | C# only |
|- [{{AssemblyTitle}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblytitleattribute.aspx] | No | C# only |
|- [{{AssemblyDescription}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblydescriptionattribute.aspx] | No | C# only |
|- [{{AssemblyConfiguration}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblyconfigurationattribute.aspx] | No | C# only |
|- [{{AssemblyCompany}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblycompanyattribute.aspx] | No | C# only |
|- [{{AssemblyProduct}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblyproductattribute.aspx] | No | C# only |
|- [{{AssemblyCopyright}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblycopyrightattribute.aspx] | No | C# only |
|- [{{AssemblyTrademark}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblytrademarkattribute.aspx] | No | C# only |
|- [{{AssemblyCulture}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblycultureattribute.aspx] | No | C# only |
|- [{{AssemblyVersion}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblyversionattribute.aspx] | Yes | Yes|
|- [{{AssemblyFileVersion}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblyfileversionattribute.aspx] | Yes | Yes|
|- [{{AssemblyInformationalVersion}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblyinformationalversionattribute.aspx] | Yes | Yes |
|- [{{AssemblyKeyFile}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblykeyfileattribute.aspx] | No | C# only |
|- [{{AssemblyKeyName}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblykeynameattribute.aspx] | No | C# only |
|- [{{AssemblyDelaySign}}|http://msdn.microsoft.com/en-us/library/system.reflection.assemblydelaysignattribute.aspx] | No | C# only |
|- [{{InternalsVisibleTo}}|http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx] | No | C# only |
|- [{{AllowPartiallyTrustedCallers}}|http://msdn.microsoft.com/en-us/library/system.security.allowpartiallytrustedcallersattribute.aspx] | No | C# only |
|- [{{NeutralResourcesLanguageAttribute}}|http://msdn.microsoft.com/en-us/library/system.resources.neutralresourceslanguageattribute.aspx] | No | C# only |
{table-plus}
AssemblyTitle
AssemblyDescription
AssemblyConfiguration
AssemblyCompany
AssemblyProduct
AssemblyCopyright
AssemblyTrademark
AssemblyCulture
AssemblyVersion
AssemblyFileVersion
AssemblyInformationalVersion
AssemblyKeyFile
AssemblyKeyName
AssemblyDelaySign
CLSCompliant
ComVisible
Guid
InternalsVisibleTo
AllowPartiallyTrustedCallers
NeutralResourcesLanguageAttribute
.Net Core csproj templates
The csproj format is supported since TeamCity 2017.1:
AssemblyName
AssemblyTitle
AssemblyVersion
Authors
Company
Copyright
Description
FileVersion
PackageId
PackageVersion
Product
Title
Version
VersionPrefix
VersionSuffix
MFC templates
The templates for replacing the following MFC C++ resource keys are are provided:
...
- Load the
AssemblyInfo
template corresponding to the attribute you are trying to process (e.g.AssemblyVersion
) - Change the list of file paths in the Look in field from the default
*/Properties/AssemblyInfo.cs
to*/CommonAssemblyInfo.cs
or list several files comma- or new-line separated files here, e.g.myproject1/Properties/AssemblyInfo.cs, myproject2/Properties/AssemblyInfo.cs
.
...
Load the
AssemblyVersion
in AssemblyInfo (C#)_ template and change the default pattern:Code Block (^\s*\[\s*assembly\s*:\s*((System\s*\.)?\s*Reflection\s*\.)?\s*AssemblyVersion(Attribute)?\s*\(\s*@?\")(([0-9\*])+\.?)+(\"\s*\)\s*\])
to
Code Block (^\s*\[\s*assembly\s*:\s*((System\s*\.)?\s*Reflection\s*\.)?\s*AssemblyVersion(Attribute)?\s*\(\s*@?\")(([0-9\*]+\.)+)[0-9\*]+(\"\s*\)\s*\])
.
and change the default replacement:Code Block $1\%build.number%$7
to
Code Block $1$5\%build.number%$7
.
...