1
votes

My web.config is like -

<configuration>
  <abc>
    <xyz>
      <service name="name1" value="value1" />
    </xyz>
    <xyz>
      <service name="name2" value="value2" />
    </xyz>
    <xyz>
      <service name="name3" value="value3" />
    </xyz>
  </abc>
</configuration>

and SetParameters.xml is

<?xml version="1.0" encoding="utf-8" ?>
<parameters>  
  <setParameter name="DummyURL" value="http://www.google.com" />
</parameters>

How should I make the parameters.xml so that through a single parameter (above) I can update the values at /configuration/abc/xyz/service[name1]/value, /configuration/abc/xyz/service[name2]/value, /configuration/abc/xyz/service[name3]/value.....(basically at all three places). At the moment my parameters.xml looks like -

<?xml version="1.0" encoding="utf-8" ?>
<parameters>
  <parameter name="DummyURL" description="a b c"
           defaultValue="default">
    <parameterEntry kind="XmlFile" scope="Web.config" match="/configuration/abc/xyz/a[@name='name1']/@value" />    
  </parameter>
</parameters>

and it is only updating at single place. I cannot add multiple xpaths through multiple parameterEntry element. Please suggest. I would not prefer to add multiple params in SetParameters.xml file as the value is same.

1

1 Answers

1
votes

To do this you can add multiple <parameterEntry /> elements in the <parameter /> element, as mentioned in section 3.c) of 'Using Deployment Parameters for Web.Config File Settings' in this article from MSDN.

So, in your case:

<?xml version="1.0" encoding="utf-8" ?>
<parameters>
  <parameter name="DummyURL" description="a b c"
       defaultValue="default">
    <parameterEntry kind="XmlFile" scope="Web.config" 
       match="/configuration/abc/xyz/a[@name='name1']/@value" />
    <parameterEntry kind="XmlFile" scope="Web.config" 
       match="/configuration/abc/xyz/a[@name='name2']/@value" />
    <parameterEntry kind="XmlFile" scope="Web.config" 
       match="/configuration/abc/xyz/a[@name='name3']/@value" />
  </parameter>
</parameters>