1

I'm creating an installation package for a service using the WIX Toolset. The installation package is working for simple xml replace but I'm unable to replace values where I have multiple nodes with the "same" path. Example xml config:

<service name="service1">
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:1234/service1" />
      </baseAddresses>
    </host>
</service>
<service name="service2">
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:1234/service2/" />
      </baseAddresses>
    </host>
</service>

Is there a simple way to replace "1234", during install, in all of the nodes using WIX (1234 is unique in the xml file)? If so, how?

If not, how can i target a specific service node? My guess is the ElementPath? I have a property [newPortValue] which contains the correct value.

<Component Id="xmlReplacerForService2" Guid="...">
    <util:XmlFile
    Id="xmlReplacerForService2"
    Action="setValue"
    File="[TESTFILEPRODUCTDIR]service.exe.config"
    SelectionLanguage="XPath"
    Permanent="yes"
    ElementPath="/service?WhatToAdd?"
    Name="baseAddress"
    Value="net.tcp://localhost:[newPortValue]/service2" />
</Component>

Is this possible?

1 Answer 1

1

Can you please try the below code and see if that works? (I am not able to test this right now, thats why.) You will have to have multiple util:XmlFile elements for each of the service entries.

<util:XmlFile
        Id="xmlReplacerForService2"
        Action="setValue"
        File="[TESTFILEPRODUCTDIR]service.exe.config"
        SelectionLanguage="XPath"
        Permanent="yes"
        ElementPath="/service[\[]@name='service1'[\]]/host/baseAddresses/add"
        Name="baseAddress"
        Value="net.tcp://localhost:[newPortValue]/service2" />
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.