在 WiX 文件中,Name="SourceDir" 代表什么?参考?
WiX 文件似乎总是包含这一行:
<Directory Id="TARGETDIR" Name="SourceDir">
什么是“SourceDir”?它有什么用?这不是真正的目录名称。难道它有某种神奇的价值吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自: https://robmensching .com/blog/posts/2010/1/26/stackoverflow-what-does-namesourcedir-refer-to/
老实说,这是我们应该向开发人员隐藏的东西,但我们没有。对不起。事实是,Windows Installer 期望目录树始终以目录行为根,其中主键 (Directory/@Id) 为“TARGETDIR”,DefaultDir 列 (Directory/@Name) 为“SourceDir” 。
在安装过程中,TARGETDIR 将默认为计算机上最大的驱动器。 SourceDir 将设置为 MSI 所在的位置被执行。现在,SourceDir 在初始安装后很棘手,因为除非调用 ResolveSource 操作,否则不会设置它。但是,您不想显式调用 ResolveSource 操作,因为它可能会提示您提供原始源媒体(又名:请插入 CD)。
我们应该在 WiX 工具集中做的是删除指定 TARGETDIR/SourceDir 对的需要,并说“任何没有父级的目录元素将自动成为 TARGETDIR 的父级,因为这就是 MSI SDK 所说的要做的事情。”相反,你必须自己做……一些开发人员想知道这意味着什么。
From: https://robmensching.com/blog/posts/2010/1/26/stackoverflow-what-does-namesourcedir-refer-to/
Honestly, it's something that we should have hidden from the developer but didn't. Sorry. The truth of the matter is that the Windows Installer expects the Directory tree to always be rooted in a Directory row where the primary key (Directory/@Id) is "TARGETDIR" and the DefaultDir column (Directory/@Name) is "SourceDir".
During an install, TARGETDIR will default to the largest drive on the machine. SourceDir will be set to the location where the MSI is being executed. Now, SourceDir is tricky after the initial install because it won't be set unless the ResolveSource action is called. However, you don't want to explicitly call the ResolveSource action because it is likely to prompt you to provide the original source media (aka: insert the CD, please).
What we should have done in the WiX toolset is remove the need to specify the TARGETDIR/SourceDir pair and say "Any Directory element that has no parent will automatically be parented to TARGETDIR because that's what the MSI SDK says to do." Instead, you have to do it yourself... and some devs wonder what it all means.
在 wix.chm 文档中,主题“如何:将文件添加到安装程序”:
根据 MSDN 文档 TARGETDIR 是
另外根据MSDN, SourceDir 是
因此 SourceDir 属性指向一个真实的目录:您的 MSI 文件所在的目录。使用
msiexec /lvx* installer.log installer.msi
安装时,您可以在安装程序日志中看到此信息。但是,由于某种原因,在解析 TARGETDIR 时 SourceDir 被完全忽略。 TARGETDIR 必须显式设置(例如在命令行上),否则解析为ROOTDRIVE。如果未显式设置 ROOTDRIVE,则它是具有最多可用空间的驱动器的根目录。
快速测试表明,将组件安装到 TARGETDIR 确实会将文件放在我的 D:\ 驱动器的根目录下,而不是 MSI 所在的文件夹中。
From the wix.chm documentation, topic "How To: Add a File To Your Installer":
According to the MSDN documentation TARGETDIR is
Also according to MSDN, SourceDir is
So the SourceDir property points to a real directory: the one where your MSI file sits. You can see this in the installer log when installing with
msiexec /lvx* installer.log installer.msi
.However, for some reason SourceDir is completely ignored when resolving the TARGETDIR. The TARGETDIR must be either set explicitly (e.g. on the command line) or else it resolves to ROOTDRIVE. If ROOTDRIVE is not explicitly set then it is the root of the drive with the most free space.
A quick test shows that installing a component to TARGETDIR indeed puts the files at the root of my D:\ drive, instead of the folder where the MSI sits.
这些对我来说都没有真正的帮助。我发现这个线程想知道如何进行调试构建,我的源文件(安装程序中的文件)可以从我试图创建的项目的“发布”构建目录或“调试”构建目录中提取的安装程序。
经过一番grep后,我在wixproj文件中找到了实际路径,其中SourceDir被定义为:
这与安装文件和项目文件实际上无关。我能够添加另一个 PropertyGroup 来镜像发布组,该发布组现在指向我的调试文件:
希望这对某人有帮助。我知道这有点偏离主题,但希望它对将来的人有所帮助。不确定为什么项目插件不公开这个值?还是我错过了?
None of this was really helpful for me. I found this thread wondering how to make a Debug build, where my source files (the ones going in the installer) could be pulled from either the "Release" build dir or the "Debug" build dir of the project I am trying to make an installer for.
After some grepping, I found the actual path in the wixproj file, there SourceDir is defined as:
which has really nothing to do with installation files and project files. I was able to add another PropertyGroup that mirrored the release group which now pointed to my debug files:
Hope this helps someone. I know it's a little off topic, but hopefully it helps someone in the future. Not sure why the project plug-in does not expose this value? Or am I missing that?