Search code examples
msbuildmsdeploy

Build once and deploy to multiple environments with msdeploy & Visual Studio 2012


Working on centralizing configurations, app settings and connection strings, for multiple solutions, while also switching over to use msdeploy from command line to deploy web apps. Ideally I would want to build the packages once, and get up-to-date configurations as the packages are deployed to each environment. I need some advice on the best approach to take.

  1. Use Parameters.xml and SetParameters.xml file to dynamically swap out settings and connection strings. See http://vishaljoshi.blogspot.com/2010/07/web-deploy-parameterization-in-action.html
  2. Use machine.config or server level web.config files to store common app settings and connection strings.
  3. Use packageweb NuGet package from https://github.com/sayedihashimi/package-web which enables using web.config transforms with msdeploy.
  4. Use file or configSource attributes along with SetParameters to point to different config files, but must be relative from web root.
  5. Use publish profiles. See Deploying an existing package using publish profiles

Thanks


Solution

  • We use option #1 and it works out well enough. We deploy to about 30-40 sites and applications using this approach.

    I think option #2 will cause headaches for either you or the developers. You'll either have to make sure the sections with settings are removed from the config on deployment, or lock them on the server so that the local config can't add them.

    For option #3 you will have to do multiple builds to get the transformed config files. It also isn't very feasible if you have a large number of sites to deploy.

    Option #4 could work, but you might run into limitations here. It's either the whole section is in a separate file or its all in the main file so there's no in-between.

    Option #5 looks interesting, but I haven't used it so I can't say much about it.