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.
Locate the web. config file in the root directory of your application (or create one if it does not already exist). Add an <appSettings> element. Add <add> child elements along with key / value pairs to the <appSettings> element as required.
If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).
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.
You could also use this way; for the prod environment for example.
<applicationSettings xdt:Transform="Replace">
<NAMESPACE>
<setting name="Testenvironment" serializeAs="String">
<value>False</value>
</setting>
</NAMESPACE>
</applicationSettings>
Regards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With