We know that Visual Studio has this great feature for converting Web.config to publishing. So we can have something like the following in Web.Release.config to replace the original value in Web.config:
Web.config:
<add key="SomeKey" value="DebugValue"/>
Web.Release.config:
<add key="SomeKey" value="ReleaseValue" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
All this is good if you do not have typos in the conversion configuration. So, for example, if your conversion configuration has the following line:
<add key="SomeKeyTypo" value="ReleaseValue" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
Then the βSomeKeyβ element will not be replaced because the conversion will not find the key and will quietly print this warning:
...\Web.Release.config: Warning : No element in the source document matches '/configuration/appSettings/add[@key='SomeKeyTypo']'
Problem is that in some situations, for example, if you change the key in the main Web.config, and you forget to change it in Web.Release.config when you publish, there is a good chance that you do not read the output messages of the publication, and you skip the warning, which may end in disaster, because the Debug value will be used in your application instead of the Release value.
So the question is is when you define a conversion in Web.Release.config, is there a way to indicate that this element MUST be replaced, and if the key is not found throw and ERROR instead of WARNING and basically exit the publication with some error code?
source share