Samselvaprabu
Samselvaprabu

Reputation: 18207

Why xmlfile action happens even the file has no other changes in wix?

We are having a web.config file installed as part of our MSI.

<Component Id="Alert" Guid="Some valid GUID">
        <File Id="Web.config" Source="..\..\..\..\<Somevalidpath>\Web.config" KeyPath="yes" />
        <File Id="Global.asax" Source="..\..\..\..\<Somevalidpath>\Global.asax" KeyPath="no" Name="Global.asax" />
        <util:XmlFile Id="SetKey_ServiceURL"
                Action="setValue"
                ElementPath="//appSettings/add[\[]@key='URL'[\]]/@value"
                Value="[SERVICEURL]"
                File="[#Web.config]"
                SelectionLanguage="XPath"
                Sequence="1" />
</Component>

In that web.config file we are upgrading a URL which is passed as a parameter to Msi via the Parameter Name SERVICEURL.

After we released our product ,due to issues we had to do minor upgrade . We decided to go with Msp rather than Msi. Now though the Web.config file has no changes , if we did not pass the parameter SERVICEURL it changes the Web.config file with empty value.

We are forced to pass the SERVICEURL again while installing the Msp though that file has no changes.

Is it possible to avoid this ? We do not want to update the URL unless there is no change.

Upvotes: 0

Views: 47

Answers (1)

PhilDW
PhilDW

Reputation: 20790

It might not be obvious, but that change is a custom action, and it runs during the patch install as well. You need something like this:

http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/util-XmlFile-conditionally-set-value-td3900952.html

where there is a condition on the CA. In your case, the condition PATCH is set during a patch, so you could use NOT PATCH as the condition.

Otherwise, use the WiX 'remember property" pattern and the property value will be preserved and restored.

Upvotes: 1

Related Questions