web.config transform at deploy time not build web.config transform at deploy time not build asp.net asp.net

web.config transform at deploy time not build


You can use the Parameterization feature of web deploy a.k.a MSDeploy. You will need to use a parameters.xml file and a setParameters.xml file to dynamically swap out settings since you are not transforming your package at build time.

At deployment time you can pass in any .xml file to set the parameters you have specified in the parameters.xml file. Since the parameters.xml is at the root of your project solution (e.g see example link of where to place the file) then at build time it gets baked into your web package. However, you now have the flexibility to change those values by passing in the setParms .xml file from the command line during deployment. This is different than transforming the values during build time based on configuration settings.

Here is a msdeploy command line example of passing in a ParamFile for a staging environment.

msdeploy -verb:sync -source:package="c:\packages\mypackage.zip" -dest:auto,computername=StagingServer1 -setParamFile="c:\StagingParameters.xml"

See the below links for examples and MSDN technical information:

Web Deploy Parameterization in Action

Parameterization vs. Web.Config Transformation

Web Deploy Operation Settings

Similar question on stackoverflow that provides several methods