I have this custom section in Web.config
<serviceWorker PriorityCronExp="__serviceWorker_PriorityCronExp__" ScheduledCronExp="__serviceWorker_ScheduledCronExp__" />
I want to replace the variables in my release, I have configured the variables and checked "XML Variable subsitution", but my release is not detecting the variables the vars are not replaced.
Other variables have been replaced correctly (defined in appSettings).
Is there a way to get the variables replaced without having to modify my Web.Config?
P.S. I am targeting .Net Framework 4.8
2
Answers
I didn’t see the whole structure of your Web.config, But I can probably tell what happened on your side.
The feature ‘XML variable substitution’ only works for applicationSettings, appSettings, connectionStrings, and configSections. Only these will work.
It is clearly clarify here:
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/transforms-variable-substitution?view=azure-devops&tabs=Classic#xml-variable-substitution
This is how it design.
If I misunderstand something, please feel free to let me know.
Yes. I suggest that you can add RegEx Match & Replace task from RegEx Match & Replace to your Pipeline to modify the web.config file.
This task will use regular expressions to match fields in the file.
Then the value will update.
You can use this site to convert the regular expressions : Regex Generator