What is the best way to handle web.config file versions in ASP.Net?

I have an ASP.Net website (ASPX and ASMX pages) with one web.config file. We have a development version and a production version. Over time, web.config files for development and production diverge significantly.

What is the best practice of storing both versions of web.config in version control (we use Tortoise SVN, but I don’t think it matters)? It looks like I can add a web.config file for production with a name like "web.config.prod", and then when we wrap all the files, we just add the step of deleting the existing web.config and renaming web.config.prod to web. config.

It seems hacky, although I'm sure it will work. Is there any mechanism for working with this built-in in Visual Studio? This seems to be a common problem, but I did not find any questions (with answers) about this.

+3
source share
3 answers

We use the exact method that you describe, it works great, for example, we have:

  • web.config (for local development)
  • web.Dev.config (build a server based on registration)
  • web.QC.config (test environment)
  • web.Prod.config (production)

script web.config . diff , . ... , , .

+3

Visual Studio 2010 adds the new XDT Transforms feature , which automatically combines multiple Web.config files for different configurations.

However, VS2008 does not include this feature.

+1
source

Source: https://habr.com/ru/post/1741026/


All Articles