Ajustes de configuración solo para desarrollo

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.

extendido
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

  • Not fill in the A.NameSpace.Settings node so the default aSettingValue se utiliza
  • Fill in the A.NameSpace.Settings node so the newly configured value is used

This 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?

preguntado el 09 de marzo de 12 a las 15:03

why not use config transforms: stackoverflow.com/questions/3004210/… -

3 Respuestas

respondido 09 mar '12, 16:03

RIGHT! I read that some time ago and totally forgot about it! - Boris Callens

Yes SlowCheetah is what u r looking for! - Sayed Ibrahim Hashimi

You could use config transforms. I will find some documentation on how to accomplish this and post it shortly.

Aquí está la hanselman article real quick that may help.

respondido 09 mar '12, 16:03

Consider using ant/maven or something like this

respondido 09 mar '12, 16:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.