Partager via


Making it easier to automate modifications to deployment binding files

Mariusz Borsa with a little tweaking from Erik Leasburg wrote this simple but nevertheless cool little utility that takes:

1. An input xml (e.g. a deployment binding file)

2. An XPath (e.g. //PrimaryTransport/Address)

3. A value (e.g. https://productionwebserver/myurl)

4. An output xml name (e.g. my modified deployment binding file)

and appropriately modifies the information in the input file creating an output file. Why do you care? You care because with it you can automate changes in binding files for nightly build processes (upping the version number in assemblies for example) or as you go from development to production.  Good stuff.

Comments

  • Anonymous
    June 10, 2004
    Oh dear. This has to be the single most useful thing I've come across for a very long time. Thanks to everyone (especially for releasing the source!)
  • Anonymous
    June 11, 2004
    NAnt has a task doing this.
    <xmlpoke>
    Replaces text in an XML file at the location specified by an XPath expression.

    The location specified by the XPath expression must exist, it will not create the parent elements for you. However, provided you have a root element you could use a series of the tasks to build the XML file up if necessary.

    The example will change the server setting in the above configuration from testhost.somecompany.com to productionhost.somecompany.com.

    <xmlpoke
    file="App.config"
    xpath="/configuration/appSettings/add[@key = 'server']/@value"
    value="productionhost.somecompany.com" />