使用 Wix 有条件安装

发布于 2024-09-05 00:59:27 字数 257 浏览 2 评论 0原文

是否可以有条件安装配置,从属于 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 技术交流群。

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

发布评论

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

评论(3

愁以何悠 2024-09-12 00:59:27

将其他两个答案和卢卡的研究放在一起,我想出了这个解决方案,似乎有效(请注意,字符串比较似乎区分大小写,并且缺少引号似乎是正确的,我已经使用 WiX 3.7 对此进行了测试):

<?if $(var.Configuration) = Debug ?>
  <!-- DEBUG ONLY -->

  [ ... insert debug only XML here ... ]

  <!-- END DEBUG ONLY -->
<?else?>
  <!-- RELEASE ONLY -->

  [ ... insert release only XML here ... ]

  <!-- END RELEASE ONLY -->
<?endif?>

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):

<?if $(var.Configuration) = Debug ?>
  <!-- DEBUG ONLY -->

  [ ... insert debug only XML here ... ]

  <!-- END DEBUG ONLY -->
<?else?>
  <!-- RELEASE ONLY -->

  [ ... insert release only XML here ... ]

  <!-- END RELEASE ONLY -->
<?endif?>
无所谓啦 2024-09-12 00:59:27

您的 wix 脚本可以访问构建参数,例如配置(“调试”或“发布”)。因此,您可以通过在组件声明中引用 $(var.Configuartion) 有条件地包含当前配置的正确二进制文件:

<Component Id="myProject.dll"
               DiskId="1"
               Guid="*">
  <File Id="myProject.dll"
            Name="myProject.dll"
            Source="..\myProject\bin\$(var.Configuration)\myProject.dll" />
</Component>

当您在发布模式下运行构建时,此脚本将获取二进制文件的发布版本。同样,在调试模式下,将拾取调试二进制文件。这种方法不需要预处理 - 脚本在构建时做出与配置相关的决策。

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:

<Component Id="myProject.dll"
               DiskId="1"
               Guid="*">
  <File Id="myProject.dll"
            Name="myProject.dll"
            Source="..\myProject\bin\$(var.Configuration)\myProject.dll" />
</Component>

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.

无所谓啦 2024-09-12 00:59:27

使用预处理器,例如: 根据配置有条件地包含/排除组件。

Use the preprocessor, e.g.: <?if?> to conditionally include/exclude components based on configuration.

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