我正在 WiX 3.7 版中设置 32 位和 64 位版本。 WiX 文档在充分解释这一点方面存在缺陷。在 documentation for Package/@Platform
,它说“不鼓励使用此属性;相反,在candle.exe 命令行中指定-arch 开关”,但没有解释此参数的实际作用(至少我找不到)。 "documentation" for the compiler完全值得围绕“文档”这个词的空气引用,因为它基本上是一个 stub (与 linker documentation 不同,例如)。对于历史记录,这里是编译器文档的全部内容:
The Windows Installer XML compiler is exposed by candle.exe. Candle is responsible for preprocessing the input .wxs files into valid well-formed XML documents against the WiX schema, wix.xsd. Then, each post-processed source file is compiled into a .wixobj file.
The compilation process is relatively straight forward. The WiX schema lends itself to a simple recursive descent parser. The compiler processes each element in turn creating new symbols, calculating the necessary references and generating the raw data for the .wixobj file.
命令行帮助提供了一些帮助,但还不够。
-arch set architecture defaults for package, components, etc.
values: x86, x64, or ia64 (default: x86)
在相关问题中,Platform identification in WiX 3.0 ,还有 one answer with a sliver of hint关于可能发生的事情,但这还不够,我不知道它是否准确。
-arch
参数与设置 Package/@Platform
的效果相同属性,还是做得更多? PLATFORM
预处理器变量?它是否设置了其他内容? Package/@Platform
属性覆盖命令行?或相反亦然?或者(更好)如果平台声明不一致,是否会出现错误? 其中一些问题的答案似乎应该是显而易见的,事实上,我只是在写这个问题时学到了一些东西。但我想要一个明确的答案,最好是(提示)指向
candle
的更新且准确的文档页面的链接。命令行。然而,我确实希望在有人回答时解决这个问题,但是我会尽快为其他人节省我花在解决这个问题上的时间。另一个相关问题,WIX: is the Platform attribute of the Package element truly deprecated? ,谈
Package/@Platform
属性,但不解决命令行参数。关于那个
PLATFORM
预处理器变量。现在显然是 BUILDARCH
,尽管您很难从文档中了解它。warning CNDL1034 : The built-in preprocessor variable '$(sys.PLATFORM)' is
deprecated. Please correct your authoring to use the new '$(sys.BUILDARCH)'
preprocessor variable instead.
最佳答案
以下代码片段启用了 32 位和 64 位版本之间的编译时配置,而无需引入代表平台的用户变量,而是使用系统提供的变量。这两个定义的变量对于普通安装都是通用的。 64 位系统的最低版本更高。基本程序文件目录在 32 位和 64 位版本之间有所不同。
<?if $(sys.BUILDARCH)="x86"?>
<?define Minimum_Version="100"?>
<?define Program_Files="ProgramFilesFolder"?>
<?elseif $(sys.BUILDARCH)="x64"?>
<?define Minimum_Version="200"?>
<?define Program_Files="ProgramFiles64Folder"?>
<?else?>
<?error Unsupported value of sys.BUILDARCH=$(sys.BUILDARCH)?>
<?endif?>
稍后在 WiX 源中使用这些定义。
<Package [...]
InstallerVersion="$(var.Minimum_Version)"
/>
<Directory Id="$(var.Program_Files)">
[...]
</Directory>
关于wix - `-arch` 命令行上的 `candle` 参数究竟是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16568901/