How to update xml with properties added by the custom action

ε祈祈猫儿з 提交于 2019-12-25 08:01:08

问题


I am building a MSI which in-turn creates a windows service.

I have a custom action which uses the archives embedded in the MSI, explodes it. After which it creates a couple of properties, which needs to be updated in the app.config of the msi. I am using <util:xmlFile> element of wix to update the config file. But then it doesnt contain the values updated in the properties.

Custom action details : After : InstallFiles Execute : "SecondSequence" // Execute Immediate throws file not found error in the custom action.

How do i go about this ?


回答1:


util:xmlFile, like most Wix stuff requires care when using properties. The File Reference is like this: File='[#RHSEXECONFIGFILE]' The Value Reference is like this: Value='[RHS_URL]' where my property is name RHS_URL. And your XPATH information has to be right.

Look at the simple example below (stolen from a working install)

<Directory Id='ProgramFiles64Folder'>
  <Directory Id='ROBINHOODCLIENTSERVICE' Name='ROBIN HOOD Client Service'>
    <Directory Id='INSTALLBINDIR' Name='bin'>
      <Component Id='MainExecutable' Guid='56F635F6-E52D-4756-A1F2-4A4190B04582' Win64="yes">
        <File Id='RHSEXE' Name='RHSClientService.exe' Source='bin\Release\RHSClientService.exe' DiskId='1' Vital='yes' KeyPath='yes' Compressed='yes'></File>
        <ServiceInstall Id='RHSEXESERVICE' Name='[ProductName]' DisplayName='[ProductName]' Description='RHS Client Service File Processor' Start='auto' Type='ownProcess' ErrorControl='normal' Vital='yes'/>
        <ServiceControl Id='RHSEXESERVICECONTROL' Name='[ProductName]' Start='install' Stop='both' Remove='uninstall'/>
      </Component>
      <Component Id='RHSEXECONFIG' Guid='C26DA00E-BD27-4E99-AB8B-E1586BF90C10' Win64="yes">
        <File Id='RHSEXECONFIGFILE' Name='RHSClientService.exe.config' DiskId='1' Source='bin\Release\RHSClientService.exe.config' Vital='yes' Compressed='yes'/>
        <util:XmlFile Id='XmlSettings1' File='[#RHSEXECONFIGFILE]'
          Action='setValue' Name='value' Value='[RHS_URL]' ElementPath="//configuration/appSettings/add[\[]@key='RHS.host'[\]]" Permanent="yes" SelectionLanguage="XPath" Sequence='1' />
        <util:XmlFile Id='XmlSettings2' File='[#RHSEXECONFIGFILE]'
          Action='setValue' Name='value' Value='RHS/services/RHSReport' ElementPath="//configuration/appSettings/add[\[]@key='RHS.uri'[\]]" Permanent="yes" SelectionLanguage="XPath" Sequence='2' />
        <util:XmlFile Id='XmlSettings3' File='[#RHSEXECONFIGFILE]'
           Action='setValue' Name='value' Value='[RHS_USERNAME]' ElementPath="//configuration/appSettings/add[\[]@key='RHS.username'[\]]" Permanent="yes" SelectionLanguage="XPath" Sequence='3' />
      </Component>
    </Directory>
  </Directory>
</Directory>


来源:https://stackoverflow.com/questions/40043204/how-to-update-xml-with-properties-added-by-the-custom-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!