Using ReplaceTokens@3:
I have an appsettings.json file which has an object like so:
{
"Data": {
"myProperty": "#{myProperty}#"
}
"myProperty2" : "{myProperty2}"
}
In my devops variable group library that is injected into my AzureDevops build, I have a key of Data.myProperty
and
myProperty2
Then I use the replace tokens task with prefix of '#{' and suffix of '}#' and target my file.
The log says 2 of 2 replaced, but when I review the outputted artifact, Data.myProperty
has not been replaced, yet myProperty2
has.
What is the correct syntax to target nested object properties?
CodePudding user response:
Replacetoken task works on Token Pattern regardless of your object is nested or not. So for your case, json file and replace token should be like.
Json File:
{
"Data": {
"myProperty": "#{myProperty}#"
},
"myProperty2" : "#{myProperty2}#"
}
This was variable group attached to pipeline.
I have tested it and this was resulting json file.