Visual Studio Team Services Build and Release extension that replace tokens in files with variable values.
Add a new task, select Replace Tokens from the Utility category and configure it as needed.
Root directory: the base directory for searching files. If not specified the default working directory will be used.
Target files: the absolute or relative newline-separated paths to the files to replace tokens. Wildcards can be used (eg: **\*.config for all config files in all sub folders).
Files encoding: the files encoding used for reading and writing. The 'auto' value will determine the encoding based on the Byte Order Mark (BOM) if present; otherwise it will use ascii.
Write unicode BOM: if checked writes an unicode Byte Order Mark (BOM).
Action: specify the action to take on a missing variable.
silently continue: the task will continue without displaying any message.
log warning: the task will continue but log a warning with the missing variable name.
fail: the task will fail and log the missing variable name.
Keep token: if checked tokens with missing variables will not be replaced by empty string.
Token prefix: the prefix of the tokens to search in the target files.
Token suffix: the suffix of the tokens to search in the target files.
Empty value: the variable value that will be replaced with an empty string.
Escape type: specify how to escape variable values.
Escape character: when using custom escape type, the escape character to use when escaping characters in the variable values.
Characters to escape: when using custom escape type, characters in variable values to escape before replacing tokens.
Verbosity: specify the level of log verbosity. (note: error and system debug are always on)
If you want to use tokens in XML based configuration files to be replaced during deployment and also have those files usable for local development you can combine the Replace Tokens task with the XDT tranform task:
create an XDT transformation file containing your tokens
setup your configuration file with local developement values
at deployment time
inject your tokens in the configuration file by using your transformation file
replace tokens in your updated configuration file
New in 3.1.0
Add Verbosity parameter to allow detail logs without using system.debug.
New in 3.0.0
Breaking change: If you were using the character escaping feature you need to select custom in Escape values type parameter.
Add support to escape JSON in variable values (contributed by Justin Gould)
Add support to escape XML in variable values (contributed by Justin Gould)
Add Windows 1252 and ISO 8859-1 encoding to File encoding (#67)
New in 2.3.0
Add support to escape characters in variable values (#52)
New in 2.2.1
Fix issue with backslash in default target files value on mac (#50)
New in 2.2.0
Fix issue on file not found when using network paths (#40, #41).
New in 2.1.0
Add support for comma-separator in Target files (#35).
Add Empty value parameter to allow token replacement with an empty string (#32).