我想继续我的顶级.wxs干,同时建立32位和64位的安装程序。我现在用的是-arch参数candle.exe来控制默认的安装架构得到建立。
I would like to keep my top level .wxs DRY while building 32 and 64 bit installers. I am using the -arch argument to candle.exe to control what default installer architecture is getting built.
在墙上,我打现在的问题是,它出现的ProgramFilesFolder在32位和64位(ProgramFiles64Folder)架构不同。这是我要解决的第一次尝试:
The wall I am hitting right now is that it appears the ProgramFilesFolder is different between 32 and 64bit (ProgramFiles64Folder) architectures. Here is my first attempt to work around:
<?if $(sys.BUILDARCH)=x64 ?>
<Directory Id='ProgramFiles64Folder' Name='PFiles'>
<?else ?>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<?endif ?>
<Directory Id='the-rest' Name="Company Name">
...
我想这一个错误。显然,preprocessor被评估之前,XML验证被激发。当我手动更改使用ProgramFiles64Folder我的构建工作。
I tried this with an error. Apparently the XML validation is fired before the preprocessor is evaluated. When I manually change to use ProgramFiles64Folder my build works.
我试图下井DirectoryRef路线没有成功。在得到这个有什么建议没有做的.wxs内的sed替换文件的工作?
I tried to go down the DirectoryRef route without success. Any suggestions on getting this to work without doing a sed replace within the .wxs file?
注:我在维克斯3.5和3.6试过这一点。
Note: I tried this in Wix 3.5 and 3.6.
而不是条件包括开幕目录
元素(该XML无效),有条件地设置$ P $这是用来作为目录名,因为@Daniel普拉特的评论是指pprocessor变量。同样,有一个是/否可变空调的平台可以很容易地设置64位组件,注册表搜索,等等。
Rather than conditionally including the opening Directory
elements (which invalidates the XML), conditionally set preprocessor variables which are used as directory names, as @Daniel Pratt's comment refers to. Similarly, having a "yes/no" variable conditioned on platform makes it easy to set up 64 bit components, registry searches, etc.
(从这个答案)
<?if $(var.Platform) = x64 ?>
<?define ProductName = "Product Name (64 bit)" ?>
<?define Win64 = "yes" ?>
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?else ?>
<?define ProductName = "Product Name" ?>
<?define Win64 = "no" ?>
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif ?>
$(var.Platform)
是内置的,但它的值是用来定义自定义变量 $(var.ProductName)
, $(var.Win64)
和 $(var.PlatformProgramFilesFolder)
。
$(var.Platform)
is built-in, but its value is used to define custom variables $(var.ProductName)
, $(var.Win64)
and $(var.PlatformProgramFilesFolder)
.
您既可以使用preprocessor &LT;如果
指令,以测试变量的值(如用 $进行(var.Platform )
定义,当自变量以上)或有preprocessor插入变量的值转换成XML属性或元素值。几个例子:
You can either use preprocessor <?if
directives to test variables' values (as is done with $(var.Platform)
when defining the custom variables above) or have the preprocessor insert variables' values into XML attribute or element values. Couple of examples:
<Component Id="..." Win64="$(var.Win64)">
...
</Component>
这将产生在Visual Studio WiX的编辑约 $(var.Win64)警告
不是允许的属性值中的一个(是
/ 没有
),但这些可以忽略,因为preprocessor将已编译器得到它保持的时间取代适当的值
This will produce warnings in the Visual Studio WiX editor about $(var.Win64)
not being one of the allowable attribute values (yes
/no
) but these can be safely ignored, because the preprocessor will have substituted an appropriate value by the time the compiler gets hold of it.
<Directory Id="$(var.PlatformProgramFilesFolder)">
...
</Directory>
在回应rharrison33的评论,询问如何处理在32位和64位安装程序为不同的产品codeS(或pretty的任何东西)的要求(假设你不能/不想自动-generate他们):
In response to rharrison33's comment asking how to handle the requirement for different product codes (or pretty much anything) in the 32 and 64 bit installers (assuming you can't/don't want to auto-generate them):
在传递单独的产品,codeS到蜡烛为preprocessor变量,在命令行或使用响应文件上:
candle <all other flags> -d ProductCode32=<guid1> -d ProductCode64=<guid2>
添加产品code为您的体系结构相关的preprocessor变量之一,并将其设置为相应的输入变量:
在32位&LT;如果&GT;
分支:???&LT;定义产品code =$(VAR 。产品code32)&GT;
在64位&LT;如果&GT;
分支:???&LT;定义产品code =$(VAR 。产品code64)&GT;
Add a product code as one of your architecture-dependent preprocessor variables, and set it to the appropriate input variable:
In the 32-bit <?if ?>
branch: <?define ProductCode = "$(var.ProductCode32)" ?>
In the 64-bit <?if ?>
branch: <?define ProductCode = "$(var.ProductCode64)" ?>
提出这一CW因为丹尼尔的环节回答了这个问题,有很多更伟大的信息之外。
Made this CW because Daniel's link answers the question and has a lot more great info besides.