7

我的公司最近强迫我们使用 Wix Toolset (v.4.0.12),因为我们升级到了 Visual Studio 2012,不幸的是它不再包含安装程序项目。

我的问题如下。我有一个包含许多项目的大解决方案,这些项目总而言之会产生一个 exe 文件和几个 dll。

然后我在解决方案中创建一个 Wix 安装项目,并添加对生成 exe 文件的项目的引用。在该项目引用的属性中,我设置了Harvest: trueProject Output Groups: Binaries.

我希望我的 WiX 项目的构建能够从引用的项目中获取依赖项,这样我就不需要手动添加引用,因为这会给我更多的维护。

此外,如果我heat.exe在引用的项目文件上运行,我只会得到文件的 exe 输出,而不是项目所依赖的 dll。

我认为以上是相当标准的,wix 工具应该能够为我收集这些信息。我真的很想知道为什么在网上广泛搜索后,找不到任何有类似问题的人。

如果有人知道上述原因,请尝试向我发送有关如何使用 WiX 进行操作的基本教程。我似乎不可能找到一个合适的。

4

3 回答 3

8

WiX v3.6 and later support VS2012. WiX v4.0 is barely even started and not recommended for use at this time. Lots of breaking changes coming in v4.0 so stick with the v3.x line for now.

The auto-harvesting feature in Votive is not fully functional. That is why it is disabled by default. Found many project types were breaking it. As you found, the harvesting does not walk through multiple project references. All things that need more work before they work properly.

In the meantime, you can list the File elements in Component elements.

于 2013-03-26T15:03:32.157 回答
2

当 v4.0.12 还没有发布时,不确定你是如何使用它的!:) Wix v3.8 是最新版本:http ://wixtoolset.org/releases 。

官方文档中有很多指南,您也可以在教程中找到很多信息。

但是,对于您的特定情况,您需要手动将每个项目的输出及其依赖项包含到安装程序中,因为尚不支持自动收获:

<Component>
    <File Id="ProjectA.Output"
          Name="$(var.ProjectA.TargetFileName)"
          Source="$(var.ProjectA.TargetPath)"
          KeyPath="yes" />
</Component>

<Component>
    <File Id="ProjectA.NlogDependancy"
          Name="NLog.dll"
          Source="$(var.ProjectA.TargetDir)\Nlog.dll"
          KeyPath="yes" />
</Component>

<Component>
    <File Id="ProjectB.Output"
          Name="$(var.ProjectB.TargetFileName)"
          Source="$(var.ProjectB.TargetPath)"
          KeyPath="yes" />
</Component>

<Component>
    <File Id="ProjectB.AutofacDependancy"
          Name="Autofac.dll"
          Source="$(var.ProjectB.TargetDir)\Autofac.dll"
          KeyPath="yes" />
</Component>

这并不难做到,除非你有几百个二进制文件,否则不会花太长时间。

于 2013-03-26T12:04:13.347 回答
1

当我尝试为我的解决方案创建 .msi 安装时,我遇到了类似的问题。

为了克服这个问题并让它随着时间的推移而持久,即使我在我的项目中插入新的 .dll 和其他依赖项并使其自动化,我做了以下操作。

在我的 Product.wxs 我有这个“目录”

<!--Here We Install Our Main App-->
<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLFOLDER" Name="MyAppDir"/>
  </Directory>
...
</Directory>

在我的 Wix 项目-> 属性-> 构建事件-> 预构建事件命令行中,我添加了以下命令:

 "%wix%\bin\heat" dir "$(SolutionDir)MainProject\bin\Debug" -dr INSTALLFOLDER -scom -frag -srd -sreg -gg -cg Components  -var var.MainProject.TargetDir -o $(SolutionDir)MainProject\Includedheat.wxs

一旦我构建了我的 wix 项目,它将在我的 MainProject 目录中创建一个 Includedheat.wxs 文件,其中列出了我的 MainProject\bin\Debug 目录中的所有文件。

下一步 - 将 Includedheat.wxs 添加到 wix 项目中,而不是在我添加的功能部分中:

<!--Add Component-->
<Feature Id="MainApplication" Title="Main Application" Level="1">
...
<ComponentGroupRef Id="Components" />
</Feature>

现在,一旦我重建并安装了 .msi,驻留在我的 MainProject\bin\Debug 目录中的所有内容也将包含在目标位置的 MyAppDir 目录中。

有关更多信息:我遵循了本指南:

创建一个工作的 Wix 项目。

简单的方法heat.exe。

还建议阅读以了解在您的命令中使用哪些标志。

于 2015-11-08T08:41:48.867 回答