How to use applicationSettings in the new web.config configuration in VS2010?

citronas picture citronas · Apr 2, 2010 · Viewed 11.3k times · Source

I'm used to use web deployment projects. Currently I am developing a new web application with VS2010 and want to try to get along with the new web.config principle and deployment issues.

How can I replace a simple setting like

<applicationSettings>
  <NAMESPACE>
   <setting name="Testenvironment" serializeAs="String">
    <value>True</value>
   </setting>
  </NAMESPACE>
</applicationSettings>

I want to have this setting to be set to True in Debug, and false in Release. How must the entries in the Web.Debug.config and Web.Release.Config look like?

And by the way: Is there some documentation about the new web.config issue? Can't seem to google for the correct keywords.

Answer

Jonathan Stanton picture Jonathan Stanton · Aug 3, 2010

The best way would be to do the following:

<applicationSettings> 
  <NAMESPACE> 
   <setting name="Testenvironment" serializeAs="String"  xdt:Transform="Replace" xdt:Locator="Match(name)"> 
    <value>True</value> 
   </setting> 
  </NAMESPACE> 
</applicationSettings> 

Rather than Zubeyir suggestion as this one will only replace the specifed setting rather than replacing the WHOLE of the applicationSettings section.