1

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 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.