0

I have a parameters.xml file for an IIS hosted web application (Which works with javascript, HTML and CSS files). In order to create a Continues Deployment sequence, I read about creating a publish profile, tokenize it with tokens and on build and release via TFS (On-Prem), tokenize and publish my web application. The problem is that I have a javascript configuration file in the client site application. I want to be able to edit it with tokens in the pipeline Iv'e already created.

My parameters xml is as follows:

<parameters>
  <parameter name="DebugOption"
    description="Some debug option."
    defaultValue="false">
  <parameterEntry  
    kind="TextFile" 
    scope="config.js" 
    match="debugOption = true" />
  </parameter>
</parameters>

As you can see, I'm matching the string "debugOption = true". What I would like to achieve is to only change the true to false, but in the tokenizer task in TFS, if I set the $(DebugOption) to be false, it replaces all of the string to false - to be specific it will replace "debugOption = true" to "false", which isn't the final result I want.

Is it any way to match this kind of string (I can't match only for true because it will replace all the 'true' occurences in the javascrip file), and only change the value, without giving the value "debugOption = false" - Only false?

Amit Ben Ami
  • 548
  • 2
  • 6
  • 21

2 Answers2

1

If replace for part of the string is not possible why don't you just replace whole word. i.e here you want to set false for debugOption so set the variable in the release section as $(DebugOption) = debugOption=false.

I hope this will work.

Thanks

abhilash
  • 45
  • 9
  • The above thing is not working since you don't have a matching rule. – abhilash Oct 24 '17 at 12:16
  • But it is working for me since the query is for the property and value and not only the value. Instead of updating only the value I’m updating the variable and its value together (the variabls’s name isn’t changing) – Amit Ben Ami Oct 24 '17 at 12:22
0

Update this could not be achieved. Just give a false to replace debugMode=true to debugMode=false; the matcher does not know which part need to be replaced.


If you are using the Tokenization Task or Tokenizer task in Release Management Utility tasks

This task finds the pattern __<pattern>__ and replaces the same with the value from the variable with name <pattern>.
Eg. If you have a variable defined as foo with value bar,
on running this task on a file that contains __foo__ will be changed to bar.

To get around match the whole string rather than each tokenized string. You need to change the RegEx slightly to not be greedy in its selection.

$regex = '__[A-Za-z0-9._-]*?__'

More details please refer this question: Tokenization based pattern replacement in web.config.token

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • I am aware that the tokenization process works with regexp but my question is how can i change only a part of my found string and not the whole string. For instance, in my case the string in the javascript file is: debugMode = true. When i deploy i want to change the false value to 'false' value, but in the match value i will set: debug = true, so the tokenizer would find it and i don't want to set the replace value to: debug = false, in prder to change only the value – Amit Ben Ami Aug 02 '17 at 16:04
  • Sorry for the misunderstanding @AmitBenAmi I'm afraid this could not be achieved. Just give a false to replace debugMode=true to debugMode=false; the matches does not know which part need to be replaced. Unless you writer your own matches for the tokenizer task in TFS. – PatrickLu-MSFT Aug 03 '17 at 10:46