如何使用 Wix 工具集检查 ini 文件是否存在 [英] How to check if ini file exists with Wix Toolset

查看:23
本文介绍了如何使用 Wix 工具集检查 ini 文件是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有配置的 .ini 文件.我需要检查它是否存在于新安装中以避免再次创建它.此外,如果新的 .ini 有新字段添加到现有文件.

I have an .ini file with configuration. I need to check if it exists in new installation to avoid creating it again. Besides if the new .ini have new fields add to the existing file.

推荐答案

不要将ini文件安装为文件,而是将条目转换成 IniFile 表条目.这允许将所有 ini 文件更改视为原子更改单元",从而允许通过内置的 MSI 机制进行正确的合并和回滚.您避免了所有自定义操作的复杂性.

正如 Chris 在他的主要升级评论中指出的那样:在 Wix/MSI 中以正确的方式做事,您可以避免在需求变化或更新变得复杂时开始出现的许多问题.以正确方式实施的 IniFile 更新功能强大且易于处理.

As Chris points out in his major upgrade comment: do things the right way in Wix / MSI and you avoid a lot of problems that start to pop up when requirements change or updates get complicated. IniFile updates implemented the right way are robust and simple to deal with.

在 Wix 中,您使用 IniFile 元素 来实现这一点.所有合并功能、回滚支持和高级 ini 文件处理都是免费提供的.您需要做的就是在安装过程中定义需要在 ini 文件中添加或修改的内容.如果它一开始不存在,它也会被创建.

In Wix you use the IniFile Element to achieve this. All merge capabilities, rollback support and advanced ini file handling comes along for free. All you need to do is to define what needs to be added or modified in the ini file during your installation. It will also be created if it is not there in the first place.

使用 IniFile 元素可能看起来比实际更难.这是一个示例.您还可以在此处查看 众所周知的 Wix 教程.

Using the IniFile element may look harder than it is. Here is a sample. You can also have a look at the well known Wix tutorial here.

所有 MSI 专家不断重复这个建议:如果有等效的内置 MSI 结构,切勿使用自定义操作来更改系统.

All MSI-experts keep repeating this advice: never use a custom action to change a system if there are equivalent built-in MSI constructs.

这篇关于如何使用 Wix 工具集检查 ini 文件是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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