.NET Configuration (app.config/web.config/settings.settings)

后端 未结 13 1298
广开言路
广开言路 2020-11-29 14:41

I have a .NET application which has different configuration files for Debug and Release builds. E.g. the debug app.config file points to a development SQL Server which has d

13条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 15:38

    Like you I've also set up 'multi' app.config - eg app.configDEV, app.configTEST, app.config.LOCAL. I see some of the excellent alternatives suggested, but if you like the way it works for you, I'd add the following:

    I have a

    for each app I add this to the UI in the titlebar: from ConfigurationManager.AppSettings.Get("Env");

    I just rename the config to the one I'm targetting (I have a project with 8 apps with lots of database/wcf config against 4 evenioments). To deploy with clickonce into each I change 4 seetings in the project and go. (this I'd love to automate)

    My only gotcha is to remember to 'clean all' after a change, as the old config is 'stuck' after a manual rename. (Which I think WILL fix you setting.setting issue).

    I find this works really well (one day I'll get time to look at MSBuild/NAnt)

提交回复
热议问题