views:

53

answers:

1

I am using msdeploy to transfer my changes(via a nant script in Team City) that I make to a site and it is great!! I have just one question, I am using msdeploy with the sync feature to make my life easier.

I currently exclude the web.config in my msdeploy because I do not know how to change the web.config on the fly. How do I change the web.config on the destination site if I do a sync?

A: 

Suppose you have a source directory with a web.config file that looks like this:

And you want to change the "name" attribute to "GoGermany"

msdeploy -verb:sync -source:dirpath=c:\source -dest:dirpath=c:\dest -setParam:type=XmlFile,match=//randomSection/@name,scope=web.config$,value=GoGermany

This will sync the two directories, while converting web.configs to change the @name attribute. The "match" subparameter is an X-Path selecting the attribute to change.

You can also do the parameter using type="TextFile" in which case you can do a regex match/replace against the entire file. The example above uses XmlFile which means an XML attribute transform.

Hope that helps.

SuperTramp