How do you handle multiple web.config files for multiple environments?

后端 未结 9 1145
野趣味
野趣味 2020-12-08 01:04

The way I currently handle this is by having multiple config files such as:

web.config
web.Prod.config
web.QA.config
web.Dev.config

When th

相关标签:
9条回答
  • 2020-12-08 01:28

    I also use the web.DEV.config, web.TEST.config, web.PROD.config etc.

    I find this way the most easiest, simplest and straight-forward way if your projects are not complex. I don't like making things more complicated than neccessary.

    However, I have used NAnt and I think it works well for this. You can set up builds for your different environments. NAnt takes some reading to learn how to use it but it's pretty flexible.

    http://aspnet.4guysfromrolla.com/articles/120104-1.aspx

    http://nant.sourceforge.net/

    I used it along with CruiseControl.net and NUnit to perform automatic daily builds with unit test validation and thought they worked well together.

    0 讨论(0)
  • 2020-12-08 01:31

    Scott Gu had an article on this once. The solution he presented was to use a Pre-build event to copy the correct config into place depending on the build configuration chosen.

    I also noticed that there already is a similar question here on SO.

    0 讨论(0)
  • 2020-12-08 01:39

    Transforms seem really helpful for this. You can replace certain sections with different rules.

    http://msdn.microsoft.com/en-us/library/dd465318(v=vs.100).aspx

    0 讨论(0)
提交回复
热议问题