Search code examples
xpathweb-configtransformationxdt-transform

Web.config transformation using xpath fails for spring resource uri


I have the following section in my vs2010 web.config file. I need to replace /bin/ with /bin/config/ in each of the resource uri in the debugging envoirment. I trying to use the xdt:transformation and locator in web.debug.config and no transformation changes is need in web.release.config that can stay the same.

    <context>
        <resource uri="~/bin/file1.config.xml" />
        <resource uri="~/bin/file2.config.xml" />
        <resource uri="~/bin/file3.config.xml" />
    </context>

I have tried couple of different approaches but nothing is working in the web.debug.config. Here is what I have which is not working. Please help.

        <resource uri="~/bin/Config/file1.config.xml" xdt:Transform="Replace" xdt:Locator="Condition(//resource[@uri='~/bin/file1.config.xml']) "/>
        <resource uri="~/bin/Config/file2.config.xml" xdt:Transform="Replace" xdt:Locator="Condition(//resource[@uri='~/bin/file2.config.xml']) "/>
        <resource uri="~/bin/Config/file3.config.xml" xdt:Transform="Replace" xdt:Locator="Condition(//resource[@uri='~/bin/file3.config.xml']) "/>

UPDATE: I need to be able to do this from visual studio IDE Debugging my website.


Solution

  • 1) First to be able run transformation from within visual studio switch between Debug, Release config files found this StackOverflow thread VS 2010 Web.config transformations for debugging

    http://ledtalks.posterous.com/webconfig-transformations-when-debugging#!/

    2) Actual transformation worked for me with changing "xdt:Locator="Condition(..." with "xdt:Locator="XPath(..."