I have a windows application and its being deployed via click once. My appsettings inside my app.config have several settings. Some settings are deployment specific like the webserver source for the file download etc. It will vary with deployment region. Some settings items are app specific which wont change during deployment.
<appSettings >
<add key="key1" value="Value111 changable with region" />
<add key="Key2" value="Value222 changable with region" />
<add key="key3" value="Value333 NOT changable with region" />
<add key="Key4" value="Value444 NOT changable with region" />
</appSettings >
Now I need to split my appsettings in two app.config files. I want to put key1 and key2 in separate config files. How do I do that.
Use the appSettings file attribute and give each deployment region its file version.
app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings file="regionsettings.config">
<add key="key1" value="default value" />
<add key="commonKey" value="common value" />
</appSettings>
</configuration>
regionsettings.config (region 1):
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="key1" value="region 1" />
</appSettings>
regionsettings.config (region 2):
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="key1" value="region 2" />
</appSettings>
Or do like Henk suggested:
<add key="region1.key1" value="region1key1 value" />
<add key="region2.key1" value="region2key1 value" />
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