如何使用自定义操作添加的属性更新xml [英] How to update xml with properties added by the custom action

查看:111
本文介绍了如何使用自定义操作添加的属性更新xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个MSI,该MSI又会创建Windows服务。

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

我有一个自定义操作,该操作使用嵌入在MSI中的档案进行分解。之后,它会创建几个属性,需要在msi的app.config中进行更新。
我正在使用wix的< util:xmlFile> 元素来更新配置文件。
但是它不包含在属性中更新的值。

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.

自定义操作详细信息:
之后: InstallFiles
执行: SecondSequence //在自定义操作中执行立即抛出未找到文件错误。

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

我该怎么办?

推荐答案

util:xmlFile ,就像大多数Wix东西一样,在使用属性时也需要小心。
文件引用是这样的:File ='[#RHSEXECONFIGFILE]'
值引用是这样的:Value ='[RHS_URL]',其中我的属性为RHS_URL。
并且您的XPATH信息必须正确。

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>

这篇关于如何使用自定义操作添加的属性更新xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆