使用 Wix 有条件安装
是否可以有条件安装配置,从属于 Visual Studio 配置环境?
例如,选择 DEBUG 或 RELEASE 配置,Wix 在构建的安装中选择不同的可执行文件。
基本上我将从相同的项目构建不同的安装,但它们的组件有所不同。某些组件是从同一项目构建的,但使用不同的预处理器选项构建。
当然,可以包含每个必需的组件,然后定义功能以便选择安装的特定组件,但我不想真正重新分发某些可执行文件。
构建不同的 Wix 项目是唯一的解决方案吗?
Is it possible to have a conditional installation configuration, slaved wth the Visual Studio configuration environment?
For example, selecting DEBUG or RELEASE configuration, Wix selects different executables in the built installation.
Basically I shall build different installations from the same projects, but they differs by the components. Some components are build from the same project, but built with different preprocessor options.
Of course it is possible to include every required component, and then define features in order to select a specific component for the installation, but I don't want really to redistribute some executables.
Build different Wix projects is the only solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将其他两个答案和卢卡的研究放在一起,我想出了这个解决方案,似乎有效(请注意,字符串比较似乎区分大小写,并且缺少引号似乎是正确的,我已经使用 WiX 3.7 对此进行了测试):
Putting the other two answers and Luca's research together I came up with this solution, which seems to work (note that the string comparison appears to be case sensitive, and the lack of quotes appears to be correct, I've tested this with WiX 3.7):
您的 wix 脚本可以访问构建参数,例如配置(“调试”或“发布”)。因此,您可以通过在组件声明中引用 $(var.Configuartion) 有条件地包含当前配置的正确二进制文件:
当您在发布模式下运行构建时,此脚本将获取二进制文件的发布版本。同样,在调试模式下,将拾取调试二进制文件。这种方法不需要预处理 - 脚本在构建时做出与配置相关的决策。
Your wix scripts have access to build parameters, like the Configuration ('debug' or 'release'). You can therefore conditionally include the correct binaries for the current configuration by referencing $(var.Configuartion) in your component declarations:
When you run the build in release mode, this script will pick up the release version of the binary. Likewise, in debug mode, the debug binary will be picked up. This approach does not require preprocessing - the script makes Configuration-related decisions at build time.
使用预处理器,例如:
根据配置有条件地包含/排除组件。
Use the preprocessor, e.g.:
<?if?>
to conditionally include/exclude components based on configuration.