I have a pipeline set up in Azure which uses variables to replace values in a XML config file when run. I traced a bug in the application back to the config file not having the correct value and I can see from the pipeline logs the expected value is not substituted in.
I initially thought this was because I'd used self closing tags, but replacing them with full tags didn't fix the issue, replacing them with a whitespace value didn't fix the issue.
In other respects the pipeline works fine. My testing has shown it will replace a non-empty value, with either an empty or non-empty value. But I cannot get it to replace and empty value with anything. So I don't think it's anything obvious e.g. it's not skipping substitution entirely, it can match the variables, the varaibles are in the applicationSettings
section, etc. Searches only seem to show things a few years old and are generally replacing a non-empty value with an empty value, which is the opposite of what I'm trying.
I could, in the default config file put in dummy values and replace them with empty/non-empty values as required, but this would involve adding a bunch of variables to the pipeline only to substitute them with empty values in most cases. It would also mean I'd need to remember to add any new entries in the config file with a dummy value and update the pipeline accordingly.
Has anyone else come across this issue? And if so, did you resolve it and how?
An example of my config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
...
<applicationSettings>
<App.Namespace>
<setting name="Test1" serializeAs="String">
<value />
</setting>
<setting name="Test2" serializeAs="String">
<value></value>
</setting>
<setting name="Test3" serializeAs="String">
<value> </value>
</setting>
<setting name="Test4" serializeAs="String">
<value>dummy</value>
</setting>
</App.Namespace>
</applicationSettings>
...
</configuration>
Pipeline variables
Test1 -> Value1
Test2 -> Value2
Test3 -> Value3
Test4 -> Value4
Output config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
...
<applicationSettings>
<App.Namespace>
<setting name="Test1" serializeAs="String">
<value /> <!-- Expected Value1 -->
</setting>
<setting name="Test2" serializeAs="String">
<value></value> <!-- Expected Value2 -->
</setting>
<setting name="Test3" serializeAs="String">
<value> </value> <!-- Expected Value3 -->
</setting>
<setting name="Test4" serializeAs="String">
<value>Value4</value> <!-- Correct -->
</setting>
</App.Namespace>
</applicationSettings>
...
</configuration>