我正在使用WixUI_Advanced序列来允许用户选择每台机器或每用户安装并更改目标文件夹。我的 WiX 项目旨在生成x86和x64 MSI(我正在使用WiX 提示和技巧建议)。我还将应用程序安装文件夹保留在注册表中以进行重大升级(根据 WixUI_Advanced 要求,我使用 APPLICATIONFOLDER 属性和目录 ID——而不是 INSTALLLOCATION)。
WixUI_Advanced 序列中存在一个错误,导致目标文件夹对话框在 64 位计算机上运行时在C:\Program Files (x86)下而不是C:\Program Files下显示应用程序文件夹,即使代码正确设置应用程序也是如此文件夹到ProgramFiles64Folder属性。错误跟踪器评论建议使用SetDirectory元素来设置 APPLICATIONFOLDER 的值,但没有示例解释如何做到这一点。当我尝试时,它确实有点不同(我还发现许多帖子建议使用自定义操作来设置 APPLICATIONFOLDER,但没有一个对我有用)。有谁知道如何让 WixUI_Advanced 序列在 64 位系统上显示正确的“程序文件”文件夹(并在主要升级期间显示最初选择的文件夹)?
如果有帮助,我将提供示例 WXS 片段,但它们几乎遵循 StackOverflow 的WiX 提示和技巧帖子中的建议。另外,我的 64 位 MSI 包确实是 64 位包(我将包和组件标记为“x64”;它不能在 32 位平台上运行)。我使用的是 WiX 3.6 和 Visual Studio 2010 .
代码示例:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product
Id="81955f17-31f3-4e51-8294-372f96141c00"
Name="WiX64BitDemo"
Language="1033"
Version="1.0.0.0"
Manufacturer="Test"
UpgradeCode="5bed9777-bea6-4dc3-91d7-5dd93819563a">
<Package
InstallerVersion="300"
Compressed="yes"
InstallScope="perMachine"
Platform="x64" />
<MajorUpgrade
AllowSameVersionUpgrades="no"
DowngradeErrorMessage="Can't downgrade."
Schedule="afterInstallInitialize" />
<Media
Id="1"
Cabinet="media1.cab"
EmbedCab="yes" />
<Property Id="APPLICATIONFOLDER" Secure="yes">
<RegistrySearch Id="FindInstallLocation"
Root="HKLM"
Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[WIX_UPGRADE_DETECTED]"
Name="InstallLocation"
Type="raw"
Win64="yes" />
</Property>
<Property Id="ApplicationFolderName" Value="WiX64BitDemo" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<SetDirectory
Id="APPLICATIONFOLDER"
Value="[ProgramFiles64Folder][ApplicationFolderName]">APPLICATIONFOLDER=""</SetDirectory>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="APPLICATIONFOLDER" Name="WiX64BitDemo">
<Component
Id="ReadmeComponent"
Guid="*"
Win64="yes">
<File
Id="ReadmeFile"
Name="readme.txt"
Source="$(var.ProjectDir)readme.txt"
KeyPath="yes"/>
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="WiX64BitDemo" Level="1">
<ComponentRef Id="ReadmeComponent" />
</Feature>
<UI Id="UISequence">
<UIRef Id="WixUI_Advanced"/>
</UI>
</Product>
</Wix>
非常感谢 Sascha Beaumont 解决了这个问题。这是工作示例:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product
Id="81955f17-31f3-4e51-8294-372f96141c00"
Name="WiX64BitDemo"
Language="1033"
Version="1.0.0.0"
Manufacturer="Test"
UpgradeCode="5bed9777-bea6-4dc3-91d7-5dd93819563a">
<Package
InstallerVersion="300"
Compressed="yes"
InstallScope="perMachine"
Platform="x64" />
<MajorUpgrade
AllowSameVersionUpgrades="no"
DowngradeErrorMessage="Can't downgrade."
Schedule="afterInstallInitialize" />
<Media
Id="1"
Cabinet="media1.cab"
EmbedCab="yes" />
<Property Id="APPLICATIONFOLDER" Secure="yes">
<RegistrySearch Id="FindInstallLocation"
Root="HKLM"
Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[WIX_UPGRADE_DETECTED]"
Name="InstallLocation"
Type="raw"
Win64="yes" />
</Property>
<Property Id="ApplicationFolderName" Value="WiX64BitDemo" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<SetDirectory
Id="APPLICATIONFOLDER"
Value="[ProgramFiles64Folder][ApplicationFolderName]">APPLICATIONFOLDER=""</SetDirectory>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="APPLICATIONFOLDER" Name="WiX64BitDemo">
<Component
Id="ReadmeComponent"
Guid="*"
Win64="yes">
<File
Id="ReadmeFile"
Name="readme.txt"
Source="$(var.ProjectDir)readme.txt"
KeyPath="yes"/>
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="WiX64BitDemo" Level="1">
<ComponentRef Id="ReadmeComponent" />
</Feature>
<UI Id="UISequence">
<UIRef Id="WixUI_Advanced"/>
</UI>
<CustomAction
Id="OverwriteWixSetDefaultPerMachineFolder"
Property="WixPerMachineFolder"
Value="[APPLICATIONFOLDER]"
Execute="immediate"
/>
<CustomAction
Id="SetARPINSTALLLOCATION"
Property="ARPINSTALLLOCATION"
Value="[APPLICATIONFOLDER]"
/>
<InstallUISequence>
<Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
</InstallUISequence>
<InstallExecuteSequence>
<Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
<Custom Action="SetARPINSTALLLOCATION" After="InstallValidate"/>
</InstallExecuteSequence>
</Product>
</Wix>