我一直在研究制作安装程序的各种不同方法(请参阅 如何为 Windows 创建一个强大的、最小的安装程序?了解详细信息),我在其中几个(WiX 和 Visual Studio 安装程序创建器)中遇到了同样的事情;似乎没有办法说“构建安装程序时,包含与 c:\somefolder\*.xml 匹配的每个文件”。
我可以选择 *.xml 并立即添加与项目匹配的所有文件,但如果稍后我将另一个 .xml 文件添加到我的程序中,我需要自己将其添加到安装程序中。
这是 Windows 安装程序的核心限制吗?我不能只是告诉它“将此文件夹中的所有 XML 文件排序出来,不要打扰我”?
I've been looking at various different ways of making an installer (see How to create a robust, minimal installer for Windows? for details), and I've run into the same thing in a couple of them (WiX and the visual studio installer creator); there doesn't seem to be a way to say "When you build the installer, include every file matching c:\somefolder\*.xml".
I can go and select *.xml and add all the files that match to the project at once, but then if I add another .xml file to my program later, I'd need to go and add that to the installer myself.
Is this a core limitation of windows installer, that I can't just tell it "sort all the XML files in this folder out and don't bother me about them"?
发布评论
评论(2)
WiX 工具集 包含一个名为 热。它可以根据您的需求为您生成 WiX 创作。输出可以通过 XSL 模板(
-t
开关)进一步转换。希望这有帮助。
WiX toolset contains an utility called Heat. It can generate the WiX authoring for you based on your needs. The output can be further transformed by XSL templates (
-t
switch).Hope this helps.
InstallShield 也有这个(请参阅动态文件链接),但老实说,我一般不喜欢这种模式。它本质上是不确定的。当我说如果从我的应用程序中添加或删除一个文件时,我想从我的应用程序安装程序中显式添加或删除它,我是根据 14 年的经验来说话的。任何自动化的魔法总是让我感到困扰,因为它会将本应是构建时错误的内容变成运行时错误。
我的最佳实践是编写一些自动化程序,将可使用的内容与安装程序使用的内容进行比较。两个列表必须 100% 匹配,否则构建失败。当构建失败时,您必须选择将文件添加到安装程序或停止将文件存档到目录。使用正确的工具,将文件添加到安装程序非常简单,并且结果是应用到安装程序的开发人员意图 100% 准确。
InstallShield also has this ( see Dynamic File Linking ) but honestly I don't like this pattern in general. It's non-deterministic in nature. I speak from 14 years of experience when I say that if a file is added or removed from my application I want to explicitly add it or remove it from my applications installer. Any magic to automate this has always bitten me in that it takes what should have been a build time error and turns it into a run time error.
My best practice is to write some automation that compares what was available to be consume against what was consumed by the installer. The two lists must match 100% or otherwise fail the build. When the build fails you must choose to either add the file to the installer or cease to archive the file to the directory. With the right tooling, it's trivial to add a file to the installer and the result is 100% accuracy of developer intent being applied to the installer.