WiX 在配置文件上搜索和替换

发布于 2024-07-29 17:22:54 字数 575 浏览 4 评论 0原文

我正在尝试使用 WiX 进行安装,并且需要使用自定义 WiX 对话框的条目修改配置文件(不是 XML 或 INI)。

有没有好的方法可以做到这一点? 我是否需要制作一个 VB 脚本自定义操作?

以下是 wxs 文件的相关部分:

   <Directory Id="TARGETDIR" Name="SourceDir">
     <Directory Id="ProgramFilesFolder">
         <Directory Id="INSTALLLOCATION" Name="MyApp">
             <Component Id="ap_cfg" KeyPath="yes" Guid="...">
                 <File Id="CONFIGFILE" Source="myConfig.cfg" />
              </Component>
         </Directory>
      </Directory>
   </Directory>

I'm trying to make an install using WiX and I need to modify a configuration file (not XML or INI) with entries that a customized WiX dialog.

Is there a good way to do this? Do I need to make a VB script custom action, perhaps?

Below is the relevant bits of the wxs file:

   <Directory Id="TARGETDIR" Name="SourceDir">
     <Directory Id="ProgramFilesFolder">
         <Directory Id="INSTALLLOCATION" Name="MyApp">
             <Component Id="ap_cfg" KeyPath="yes" Guid="...">
                 <File Id="CONFIGFILE" Source="myConfig.cfg" />
              </Component>
         </Directory>
      </Directory>
   </Directory>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

嘿嘿嘿 2024-08-05 17:22:54

搜索和搜索中没有构建。 替换 Wix 中的构造,您将需要编写自定义操作。
我建议您不要使用 VBScript,而是使用 DTF< /a> 这将使您能够在 .net 中编写自定义操作并在 Visual Studio 下对其进行调试。

There is no build in Search & Replace construct in Wix, you will need to write a custom action.
I suggest that instead of using VBScript you will use DTF which will enable you to write the custom action in .net and debug it under Visual Studio.

孤云独去闲 2024-08-05 17:22:54

那么您想通过在安装过程中动态修改它来安装配置文件吗?

您最好使用本机/非托管代码(例如 C++)编写自定义操作,该代码读取各种 MSI 属性并将它们写入您的配置文件。 无论如何不要安装带有密钥路径的文件,否则一旦修改,它就不会与原始哈希匹配,并且将被修复。 最好从二进制表或其他内容中写出“默认”配置,然后修改它,这样 Windows 安装程序就不会关心你用它做什么。

我也不建议为您的自定义操作使用托管代码,使用 C++,您会在以后避免很多麻烦。 WiX 工具集源代码中有一些非常好的示例可以帮助您入门。

最后,在您考虑使用 VBScript 之前,请先阅读一下为什么VBScript(和 Jscript)MSI CustomActions 很糟糕

So you want to install a config file, by modify it dynamically during installation?

You're better off writing a custom action in native/unmanaged code like C++ that reads the various MSI properties and writes them out to your config file. Don't install the file with a keypath at any rate, otherwise as soon as it's modified it won't match the original hash and will be repaired. Better to just write out the "default" config from the binary table or something and then modify it, that way windows installer doesn't care what you do with it.

I wouldn't advise using managed code for your custom actions either, use C++ and you'll save yourself a lot of headaches down the road. There are a few very good examples in the WiX toolset source to get you started.

Finally, before you even think about using VBScript go and read why VBScript (and Jscript) MSI CustomActions suck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文