如何在构建安装包时自动选择源文件

发布于 2024-10-17 04:41:29 字数 85 浏览 9 评论 0原文

我有以下要求: 两个文件夹A和B,对于文件a,如果它存在于A中,我们将其构建到我们的安装包中,否则我们使用文件夹B中的文件a作为默认选择。如何实施?请帮忙。

i have the following requirement:
two folders A and B, for file a, if it exists in A, we build it into our install packet, otherwise we use file a in folder B as the default selection. how to implement this? please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

顾冷 2024-10-24 04:41:29

我想说这项工作应该在 WiX 和你的构建引擎之间分配。此外,大部分责任都在建造引擎。

在 WiX 中,您可以通过以下方式创作相关文件(我们称之为 a.txt)(它是 Component 元素的子元素):

  <File Id="myfile" KeyPath="yes" Source="$(var.DataFolder)\a.txt" />

这样,您应该将 DataFolder 变量的值传递给Candle.exe(WiX 的编译器)。这可以通过多种方式完成,通过命令行或通过项目设置(如果您创作 *.wixproj)。假设您使用第一个选项进行操作,并且您的构建引擎是 NAnt:

  <candle out="${out}\\" rebuild="true">
     <defines>
        ...
        <define name="DataFolder" value="${data.folder}" />
        ...
     </defines>
     <sources basedir="${dir}">
        <include name="**.wxs"/>
     </sources>
  </candle>

请注意,这只是一个供您了解想法的示例。 WiX 还与 MSBuild 友好

然后,构建引擎负责选取正确的 ${data.folder},在您的情况下是 A 或 B。

I would say this job should be split between WiX and your build engine. Moreover, the most of the responsibility goes to build engine.

In WiX you can author the file in question (let's call it a.txt) in the following way (it's a child of a Component element):

  <File Id="myfile" KeyPath="yes" Source="$(var.DataFolder)\a.txt" />

Having that, you should pass the value of DataFolder variable to candle.exe (the compiler of WiX). This can be done in a couple of ways, via the command line or via the project settings (if you author *.wixproj). Let's say, you're doing it with the first option and your build engine is NAnt:

  <candle out="${out}\\" rebuild="true">
     <defines>
        ...
        <define name="DataFolder" value="${data.folder}" />
        ...
     </defines>
     <sources basedir="${dir}">
        <include name="**.wxs"/>
     </sources>
  </candle>

Note that it's just a sample for you to get the idea. WiX is also friendly with MSBuild.

The build engine is then responsible for picking up the correct ${data.folder}, whch is either A or B in your case.

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