#Usage of this extension:
To replace variables in config files for .net projects.
The extension contains a task which you can use in TFS build or release.
##How to use the task:
Folder Path --> Enter the folder path (make sure it is a folder path and not a file path). You can enter multiple folders each in 1 line without any other delimiter
FilePattern --> The pattern to use to filter files. For example, use *.txt to search for all .txt files. You can enter multiple file pattern each in 1 line without any other delimiter
Replace Undefined variables with empty values? --> (Applicable from version 2.1.*)Mark this field if you would like the undefined variables in the files should be replaced with empty value
####Under Advanced Group:
Recursive? --> To search for the file pattern in all sub-folders as well
Regex Pattern --> The regular expression pattern to use for searching the variables in the files. For example __(\w+)__ searches for all words of the format __word__ and __(\w+[.\w+]*)__ searches for all words of the format __word.word.soOn__. This is a multi line field. You can give any number of patterns, 1 in each line without any other delimiter
Secret Variables --> (Obsolete from version 2.1.*) ~~(Applicable from version 2.0.0)Mention the secret variables in the format VariableName:$(VariableName) 1 in each line. Eventually you should have defined the secret variables in build definition or in release definition.~~
##Prerequisites for the task to work:
Conventionally the files should have variables defined in the format of __VariableName__ and the variables should be defined in the build definition or release definition without __.
For example, let's consider the file has an entry called variable123 in the format __variable123__. In order to replace this entry define the variable without __ in the build or release definition as variable123.
For this above convention the regex pattern __(\\w+[\\.\\w+]*)__ works fine.
If you have variables of different convention in the files then you would need to define the regex pattern and release/build definition variables accordingly.
##What the task does:
For each folder path for each file pattern for each Regex pattern the task searches for the variables of the format mentioned in Regex pattern and replaces them if there are any values defined for those variables
In build variables for build tasks &
The task will be able to handle below scenarios as well:
If you have a variable in variable group whose value is another variable then the task will evaluate and get the value.
For example, in a variable group if you have a variable named SampleVariable and value as $(ChildVariable) and you have defined ChildVariable in one of the environment of the Release Definition, then the task will evaluate the value of ChildVariable and fill it as value for the variable SampleVariable.
##Updates with latest version 2.1.*:
Support for variable names with . in them is added ! So far in version 2* this feature was not available.
Support for replacing undefined variables with empty values is added ! Select the boolean field Replace Undefined variables with empty values? to replace undefined variables with empty values.
Support For Secret Variables is native without any extra effort ! Hence the previously used field Secret Variables introduced in version 2* is no more needed.
##Updated with latest version 2.0.0:
Support For Secret Variables is added !
How it works?
~~Let's say you have a secret variable in the release definition as SecretVar. In order for the task to update the files with the secret value, you need to define the secret variables in the input of the task under Secret Variables in Advanced group, in the format SecretVar:$(SecretVar). You can give multiple variables 1 in each line.~~