WiX:定义一个可能不存在的File组件
我需要定义一个在某些情况下可能不存在的 Wix 文件组件。有什么办法可以做到这一点吗? Wix 中的条件元素似乎都在安装时起作用,我需要一些可以在编译时检测文件是否存在并相应地构建安装程序的东西。
I need to define a Wix file component that may not exist in certain circumstances. Is there any way to do this? Condition elements in Wix all seem to work at install time, and I need something that'll detect at compile time if a file is present and build the installer accordingly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来你需要检查一下 wix 预处理器。查看有关该主题的 wix 文档:
wix 预处理器
例如,假设您有一个名为 APPTYPE 的环境变量。如果其值设置为“Full”,则 MyApp_Full.exe 将由 wix 编译器(蜡烛)包含并处理。
还有更多!变量、定义、条件。查看该文档页面。
It seems you need to check out the wix preprocessor. Check out wix documentation on the topic:
wix preprocessor
for example, suppose you have an environment variable called APPTYPE. If its value is set to 'Full', then MyApp_Full.exe will be included and processed by the wix compiler (candle).
There is more! Variables, defines, conditionals. Check out that doc page.
正如 iwo 所说,预处理器变量是你的朋友!然而,来自 iwo 的示例可能(并且将会)违反组件规则,因为该组件不是“稳定”的。更好地调节整个组件(或组件组)...
然后将
Component
和ComponentGroup
包含在单独的Fragment
标记中,以便它们仅在引用时才会编译:)我个人使用 nant 来调用
candle
并light
目标,为各种不同的构建和产品定义不同的变量,片段和预处理器变量的有效使用为项目之间或同一项目的不同版本之间的代码重用提供了很好的机会。在您的情况下,要检查文件是否存在...那么您只需使用内部函数来定义或重新定义稍后传递给 WiX 的变量。例如:
As iwo said, preprocessor variables are your friend! However the example from iwo can (and will) violate component rules, as the component isn't 'stable'. Better to condition an entire component (or component group)...
And then include the
Component
andComponentGroup
s in separateFragment
tags so that they will only be compiled when referenced :)Personally I use nant to call
candle
andlight
targets, defining different variables for various different builds and products, effective use of fragments and preprocessor variables provides a great opportunity for code re-use between projects, or various releases of the same project.In your case, to check if a file exists... then you'd just use the internal functions to define, or redefine a variable that is later passed to WiX. e.g.: