Different application settings depending on configuration mode

后端 未结 6 1890
生来不讨喜
生来不讨喜 2020-12-08 05:15

Is anyone aware of a way that I can set application (or user) level settings in a .Net application that are conditional on the applications current development mode? IE: Deb

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 05:45

    This is somewhat late to the party, but I stumbled upon a nice way of implementing the web.transform approach for app.config files. (i.e. it makes use of the namespace http://schemas.microsoft.com/XML-Document-Transform)

    I think it is "nice" because it is a pure xml approach and doesn't require 3rd party software.

    • A parent / default App.config file is descended from, according to your various build configurations.
    • These descendants then only override what they need to.

    In my opinion this is much more sophisticated and robust than having to maintain x number of config files which get copied in their entirety, such as in other answers.

    A walkthrough has been posted here: http://mitasoft.wordpress.com/2011/09/28/multipleappconfig/


    Look, Mom - No explicit post-build events in my IDE!

提交回复
热议问题