How to use different .settings files for different environments in .NET?

前端 未结 6 847
温柔的废话
温柔的废话 2021-02-02 01:11

.NET allows you to use .settings files to manage application settings. I would like to store Production, Development and Test settings separately in a way that I can do somethi

6条回答
  •  执笔经年
    2021-02-02 01:59

    I am using this approach for .config files, I am sure that it will help you too. Just look on Scott Hanselman's blog post and this question. Ideology is simple like hell, but works pretty good. All you will need is:

    1. create several files for different configurations
    2. name them by convention, e.g. my.dev.settings, my.live.settings
    3. create post build event (see links)
    4. enjoy =)

    Instantiation code for you class with settings will always look in default settings (which will be replaced after each build with the needed one), so this approach require minimal effort.

提交回复
热议问题