简体   繁体   中英

Automated deployment to many servers with different app.config settings?

I know there are many questions like this one on SO, but I haven't found a good solution so far. The best solutions I've seen are homegrown, but before implementing a custom tool, I'd like to hear your take. So here we go:

I have a .NET solution with a couple of web applications and a few windows services. I want to automate the rollout of these applications to, say, 10-20 different servers - but the app/web.config files on each server may have different values.

Microsoft's answer to this issue is to have 10-20 different web.config files locally on the dev machine, and then using configuration manager to choose the right one. But that's not good enough, because the developers don't know about the production server settings, nor should they!

The ideal solution would be to include a "deployment model" of some sort where the production servers and their settings are defined, and which could be used with some deployment script (could be Powershell ) as a step in the build server (I'm using TeamCity ). This could be done by replacing the config settings before XCopying the solution to the remote server. But it's a tedious and time consuming task.

Another solution could be to use "configSource" to point to a folder with a fixed name, but the problem here is that some parts of the config files (such as serviceModel) can't be used with configSource.

So I haven't found the best answer to this. Any ideas?

Part of our deployment model (also a TeamCity centralised build going to many different servers) was to automatically create deployment scripts as part of the MSBUILD file and base the deployment around MSDEPLOY/web deployment 2.0.

The build would automatically produce a build candidate suitable for deployment with MSDEPLOY and would also knock up a powershell/cmd scriptlet that would pick the appropriate config file and copy it into place.

A deployment to all servers then just becomes a case of stringing these individual deployment scripts together (ie with a batch file). Since MSDEPLOY only sends over file changes it's normally quite speedy, and can be used to take backups as well as do deployments, so as part of the deploy script it will:

  1. Take a backup of the appropriate server (eg Web1) and stick it on a network share
  2. Deploy the appropriate package to the server (Web1) transforming any files as necessary (eg Web.Web1.Config -> Web.config)
  3. Write any necessary logs

The build process also spits out an 'undo' script that will restore the appropriate server to the backup.

There's more on MSDEPLOY here . It can also be used with databases etc.

Just a suggestion, it might be helpful :)

[Blatant vendor post] We use exactly this sort of deployment model in our uDeploy product.

The basic idea is that you define a single deployment process that includes steps for updating configuration files (app.config and web.config are the most normal for ASP apps). Those variances can be per server or per logical environment (dev test, qa, stage, prod...). Alternately, you can put a template app.config file directly in uDeploy and we will write it out at deployment time.

The tool integrates with TeamCity to retrieve builds as well as IIS for deployment and configuring application pools and servers. It's also designed to track how multiple services and web applications that might be different TeamCity builds, come together as a release set.

On the surface, it sounds like we might have a decent fit. Feel free to reach out to me directly at eric@urbancode.com. Cheers! [/blatant vendor post]

I'm using XmlPreprocess tool for config files manipulation. It is using one mapping file for multiple environments/servers. You can edit mapping file by Excel. It is very easy to use. Call XmlPreprocess in your custom PS scripts and pass server name as environment parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM