Search code examples
.netbuildnant

How to change specific value node in web.config through xmlpoke?


I am using Nant for build process. I need to change my web.config file to set end point address. My web.config file contains 5 endpoint address and I need to change endpoint address of those node which name is like "service1"

<endpoint address="" binding="wsHttpContextBinding"

 bindingConfiguration="WSHttpContextBinding_Iservice1" contract="xyz" name="**service1**">

Solution

  • You will need to create a target that calls xmlpoke

    Sample code:

    <xmlpoke
    file="Web.config"
    xpath="/configuration/system.ServiceModel/services/service/endpoint[@name = 'service1']/@address"
    value="127.0.0.1:8080" />