We know that Visual Studio has this awesome feature to transform Web.config on publish. 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)"/>
This is all good as long as you don't have a typo in the transform config. So for instance if you have the following line in your transform config:
<add key="SomeKeyTypo" value="ReleaseValue" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
Then "SomeKey" item is not going to be replaced because transform will not find the key and will silently print this warning:
...\Web.Release.config: Warning : No element in the source document matches '/configuration/appSettings/add[@key='SomeKeyTypo']'
The problem is that under some situations like 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 don't read the publish output messages and you miss the Warning, which can end up in disaster because the Debug value will be used in your application instead of the Release value.
So the question is when you define the transform in Web.Release.config is there a way to indicate that the given item MUST be replaced and if the key is not found throw and ERROR instead of WARNING and basically exit the publish with some error code?