为什么 TARGETDIR 目录需要一个名称? [英] Why does the TARGETDIR directory need a name?

查看:17
本文介绍了为什么 TARGETDIR 目录需要一个名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 wix 项目中,您通常会看到类似的一行

<Directory Id="TARGETDIR" name="SourceDir">

但是为什么这里需要设置name呢?据我了解, name 属性指定了在进行安装的机器上生成的文件夹的名称.但是不会创建 SourceDir 文件夹,为什么需要它呢?

解决方案

更新:事实证明,这个问题以前被问过.查看这篇文章以获取 Wix 创建者 Rob Mensching 的解释:

目录解析后,SourceDir 将指向运行 MSI 的路径.此外,TARGETDIR 将是大多数内置 Windows 目录(如 ProgramFilesFolder 和 ProgramMenuFolder)的父文件夹,如上图所示.

因此,简而言之,SourceDir 被定义为保存正在运行的 MSI 文件的位置,并且必须知道该位置才能解析分发媒体上要安装的每个文件的源位置.

目标位置是文件的完整安装路径:C:Program FilesMy App(文件所在的位置).源位置是文件的完整源路径:[SourceDir]Program FilesMy App(文件的来源).

已经晚了,如果不清楚,请告诉我.

In wix projects you will generally see a line like

<Directory Id="TARGETDIR" name="SourceDir">

But why does the name need to be set here? From what I understand the name property specifies the name of the generated folder on the machine doing the installing. But no SourceDir folder will be created, so why is it needed?

解决方案

UPDATE: It turns out this question has been asked before. Check this post for an explanation from Wix creator Rob Mensching: In WiX files, what does Name="SourceDir" refer to?


TARGETDIR plays a special role in the resolution of an MSI file's Directory table. Specifically it forms the root of the source and target directory trees. This is indicated in the MSI file by the null value in the Directory_Parent column:

After directory resolution SourceDir will point to the path where the MSI is running from. Furthermore TARGETDIR will be the parent folder for most built-in Windows directories such as ProgramFilesFolder and ProgramMenuFolder as illustrated in the image above.

So in short SourceDir is defined to hold the location of the running MSI file, and this location is necessary to know in order to resolve the source locations on the distribution media for each file to install.

A target location is a full installation path for a file: C:Program FilesMy App (where the file is going). A source location is the full source path for a file: [SourceDir]Program FilesMy App (where the file is coming from).

It is late, please let me know if this wasn't clear.

这篇关于为什么 TARGETDIR 目录需要一个名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆