Web.config - automatic release version creation

A simple task, but for some reason not yet a simple solution.

We have web.config files and I haven’t worked anywhere yet, I have no problem when someone screams around the room "Sh * t", I just downloaded the wrong web.config file. "

Is there an easy way to automatically create a web.config file that will contain the right things to copy? An example of this is:

  • Change connection string to use real-time database
  • Edit
  • Switch to using real-time registration / release system and real-time / release security settings
  • (in our case, we need to change the SessionState mode to InProc from StateServer - this is not normal)

If you have others, let me know and I will update it here to make it easier for you to find

Maintaining 2 configuration files works, but it’s a pain in the kingdom, and usually this is the reason why something went wrong when you click on things.

+3
source share
5 answers

Visual Studio 2010 supports something like this. Check here .

+4
source

PowerShell script, web.config, XML . :

param($mode, $src)
$ErrorActionPreference = "stop"
$config = [xml](Get-Content $src)

if ($mode -eq "Production")
{
    $config.SelectSingleNode("/configuration/system.web/compilation").SetAttribute("debug", "false")
    $config.SelectSingleNode("/configuration/system.web/customErrors").SetAttribute("mode", "off")
    $config.SelectSingleNode("/configuration/system.net/mailSettings/smtp/network").SetAttribute("host", "live.mail.server")
    $config.SelectSingleNode("/configuration/connectionStrings/add[@name='myConnectionString']").SetAttribute("connectionString", "Server=SQL; Database=Live")
}
elseif ($mode -eq "Testing")
{
    # etc.
}

$config.Save($src)

script , , , . script, - -, - script script web.config. , , .

+1

XSLT XML . Web.config xml, .

.xslt ( xpath).

xml, 1. debug.config.xml 2. staging.config.xml 3. release.config.xml

postbuild msbuild xslt xml web.config.

debug.config.xml

<Application.config>
   <DatabaseServer></DatabaseServerName>
   <ServiceIP></ServiceIP>
</Application.config>

.xslt xpaths, xml, .

XSLT- MSBuild nant, web.config xml .

, xml.

, xslt, web.config. , web.config - , xslt.

0

I do not think you can avoid this 100%.

The last years of work always and always show: where a person worked, break down.

So, here are 3 ideas from my last company, not the best, maybe, but nothing is better:

  • Write a batch file or C # .Net application that will change your web.config to doubleclick
  • Write "ToDo on Release" -List
  • We implement a pair (== pair programming with realease :))
-1
source

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


All Articles