Short
I want to set certain applicationSetting values to specific values only for my development machine in a config file that cannot be checked in. For this I was thinking to use the configSource attribute with a user.config file. This attribute, however throws an exception when the file is not present.
Extended
I have a library with the following app.config file:
<applicationSettings>
<A.NameSpace.Settings>
<setting name="ASettingName" serializeAs="String">
<value>aSettingValue</value>
</setting>
</A.NameSpace.Settings>
</applicationSettings>
Another library is going to use this library and has two options and one described a bit further
aSettingValue
is usedThis is handy because our build script that prepares setups can now replace environment-dependant parameters (eg: servernames, ports etc)
Now a third option is to have a app.config like this:
<applicationSettings>
<A.NameSpace.Settings configSource="user.config" />
</applicationSettings>
and define the same value in a user.config
file that is not checked in. This is awesome.
Except that in not-dev environment this user.config file should not present and an exception will be thrown when the file is not found.
How can I define configuration values only for my dev machine?
I think SlowCheetah is what you are looking for.
Scott Hanselman blogged about it: SlowCheetah - Web.config Transformation Syntax now generalized for any XML configuration file