“Wix 4 Harvest Directory” 的解释是什么?

huangapple go评论54阅读模式
英文:

Explanation for Wix 4 Harvest Directory?

问题

I am trying to learn Wix 4.0 to create an installer for an application I am developing. Once my application is built I have a bunch of files one folder that I would like to install to program files, I have read that the harvesting functionality allows me to streamline this process and create component mappings for the entire directory, but I am not sure what this example is showing. I am curious about what the <ItemGroup> tag is, and I think I have a fundamental misunderstanding of how to point this to my directory in order to use the components.

<Project Sdk="WixToolset.Sdk">
  <ItemGroup>
    <HarvestDirectory Include="FilesDir">
      <ComponentGroupName>HarvestedComponents</ComponentGroupName>
      <DirectoryRefId>ApplicationFolder</DirectoryRefId>
      <SuppressRootDirectory>true</SuppressRootDirectory>
    </HarvestDirectory>

    <BindPath Include="FilesDir" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="WixToolset.Heat" />
  </ItemGroup>
</Project>
英文:

I am trying to learn Wix 4.0 to create an installer for an application I am developing. Once my application is built I have a bunch of files one folder that I would like to install to program files, I have read that the harvesting functionality allows me to streamline this process and create component mappings for the entire directory, but I am not sure what this example is showing. I am curious about what the &lt;ItemGroup&gt; tag is, and I think I have a fundamental misunderstanding of how to point this to my directory in order to use the components.

&lt;Project Sdk=&quot;WixToolset.Sdk&quot;&gt;
  &lt;ItemGroup&gt;
    &lt;HarvestDirectory Include=&quot;FilesDir&quot;&gt;
      &lt;ComponentGroupName&gt;HarvestedComponents&lt;/ComponentGroupName&gt;
      &lt;DirectoryRefId&gt;ApplicationFolder&lt;/DirectoryRefId&gt;
      &lt;SuppressRootDirectory&gt;true&lt;/SuppressRootDirectory&gt;
    &lt;/HarvestDirectory&gt;

    &lt;BindPath Include=&quot;FilesDir&quot; /&gt;
  &lt;/ItemGroup&gt;

  &lt;ItemGroup&gt;
    &lt;PackageReference Include=&quot;WixToolset.Heat&quot; /&gt;
  &lt;/ItemGroup&gt;
&lt;/Project&gt;

Thanks, and I will edit with more information where needed.

答案1

得分: 4

基本上&lt;ItemGroup&gt;只是在WiX项目文件中将不同元素分组在一起。

对于整个目录的收集,以下元素很重要:

  • &lt;HarvestDirectory Include=&quot;Folder/To/Harvest&quot;&gt;: 指定要收集的文件夹的路径
  • &lt;ComponentGroupName&gt;ApplicationFilesComponent&lt;/ComponentGroupName&gt;: 指定由heat生成的组件的名称(然后您需要在安装过程中包含此组件)
  • &lt;DirectoryRefId&gt;ApplicationDirectory&lt;/DirectoryRefId&gt;: 指定文件应该写入的目录的Id(更多信息请参见:https://wixtoolset.org/docs/schema/wxs/directory/)
  • &lt;BindPath Include=&quot;Folder/To/Harvest&quot; /&gt;: 再次,在这里指定您要收集的文件夹的路径

错误预防的提示(我曾经吃过的亏):

  • 在您的包引用中包含版本,例如&lt;PackageReference Include=&quot;WixToolset.Heat&quot; Version=&quot;4.0.0&quot; /&gt;
  • 当指定文件夹时,请不要使用\(反斜杠),请始终使用/(斜杠)

注意:
我不太确定为什么需要两次指定要收集的路径(文档中缺少这一点)。如果有人有更多详细信息,请评论或编辑此答案。

英文:

So basically the &lt;ItemGroup&gt; just groups together different elements in the WiX project file.

For harvesting whole directories the following elements are important:

  • &lt;HarvestDirectory Include=&quot;Folder/To/Harvest&quot;&gt;: specify the path of the folder you want to harvest
  • &lt;ComponentGroupName&gt;ApplicationFilesComponent&lt;/ComponentGroupName&gt;: specify a name for the component that will be generated by heat (you then need to include this component in your installation process)
  • &lt;DirectoryRefId&gt;ApplicationDirectory&lt;/DirectoryRefId&gt;: specify the Id of directory, where the files should be written to (More information: https://wixtoolset.org/docs/schema/wxs/directory/)
  • &lt;BindPath Include=&quot;Folder/To/Harvest&quot; /&gt;: again, specify the path of the folder you want to harvest here

Tips for error prevention (that I have learned the hard way):

  • Include the version in your package reference e.g. &lt;PackageReference Include=&quot;WixToolset.Heat&quot; Version=&quot;4.0.0&quot; /&gt;
  • When you specify the folder don't use \ (backslash), always use / (slash)

Note:
I'm not quite sure why its necessary to specify the path to be harvested two times (the documentation lacks that point). If someone has more details please comment or edit this answer.

huangapple
  • 本文由 发表于 2023年4月19日 23:23:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76056261.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定