TL; DR
Is there any way that I can use JSON variable substitution with default Release variables in VSTS?
Description
With VSTS, I can use JSON variable substitution to set values in an appsettings.json
file at release time. For example, with an appsettings.json
file that looks like this:
{
"ConnectionStrings": {
"DM_ADJ": "placeholder",
"DM_SALES": "placeholder"
},
// And so on. Placeholders get replaced
}
I can define a Release variable in VSTS called ConnectionStrings.DM_ADJ
, and the value I provide there will replace "placeholder"
in the corresponding JSON line.
Now, I would also like to use some of the default Release variables in my app's configuration. For example, there are default Release variables called Release.DefinitionName
and Release.DefinitionId
. I thought that I could substitute them into an appsettings.json
config section like below, but unfortunately, when the Release completes, the "placeholder"
strings do not get replaced. Am I missing something?
{
"Release": {
"DefinitionName": "placeholder",
"DefinitionId": "placeholder",
}
// And so on. Placeholders do not get replaced
}
This is an expected behavior since it excludes the build/release's system definition variables:
If you want to use the system definition variables in the json file, creating a custom variable and set the value to system defined variable like following instead of using system defined variable directly: