Dav Evans
Dav Evans

Reputation: 4071

web.config transform at deploy time not build

I'm wanting to know how to perform the following

From my own reading I'm unsure of how to do this. WebDeploy seems to package, transform and deploy based on a configuration but Im unsure how these steps can be decoupled to avoid the need to recompile code from source control.

Does anyone have any experience in solving this issue?

Upvotes: 19

Views: 8831

Answers (1)

SoftwareCarpenter
SoftwareCarpenter

Reputation: 3923

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

Upvotes: 11

Related Questions