msdeploy sync and web.config

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?

Answers


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

<configuration>
    <system.web>
        <randomSection name="value" name2="value2" />
    </system.web>
</configuration>

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.


Need Your Help

How to Save, Save As Java?

java swing save actionlistener

Hello I'm having a little bit of a problem with my text editor like program. I would like to have my Save feature work only if Save As has been called, and if Save is called that it appends the tex...