Search code examples
msdeploy

Is it possible to modify web.config of existing site using MSDeploy?


Is it possible to modify (or just replace) web.config of existing site using MSDeploy?


Solution

  • It's possible to replace certain sections (specified with an xPath query or regular expression) of the web config file. Use the -declareParam en -setParam commandline switches for that.

    Like so

    msdeploy -verb:sync -source:apphostconfig="Default Web Site" -dest:package=ParameterPackage.zip -declareParam:name=param,kind=XmlFile,scope=web.config,match=//add/@value 
    

    or so:

    msdeploy -verb:sync -source:package=ParameterPackage.zip -dest:auto -setParam:name=param,value=MyDefaultWebPage.htm
    

    You can find more info here if you're using the command line.

    If your working with importing and exporting packages in and from IIS you can create a parameters.xml file. Vishal Joshi has lots of good posts about how to use msdeploy (for example this)