WiX:如何在WixUI_Advanced序列中覆盖x64机器上的“C:\ Program Files(x86)”?

时间:2011-03-29 22:42:19

标签: wix windows-installer wix3.6

我正在使用 WixUI_Advanced 序列,以允许用户选择 per-machine per-user 安装并更改目标文件夹。我的WiX项目旨在生成 x86 x64 MSI(我正在使用WiX Tips and Tricks推荐)。我还将app 安装文件夹保留在注册表中进行主要升级(我使用APPLICATIONFOLDER属性和目录ID - 而不是INSTALLLOCATION - 根据WixUI_Advanced要求)。

bug in WixUI_Advanced sequence导致“目标文件夹”对话框在 C:\ Program Files(x86)下显示应用程序文件夹,而不是 C:\ Program Files 在64位计算机上运行时,即使代码正确地将app文件夹设置为 ProgramFiles64Folder 属性。错误跟踪器注释建议使用 SetDirectory 元素来设置APPLICATIONFOLDER的值,但有无示例解释如何执行此操作。当我尝试时,它确实有点不同(我还发现一些帖子建议使用自定义动作设置APPLICATIONFOLDER,但没有一个对我有效)。有谁知道如何使WixUI_Advanced序列在64位系统上显示正确的'Program Files'文件夹(并在主要升级期间显示最初选择的文件夹)?

如果有帮助,我会提供示例WXS代码段,但它们几乎都遵循StackOverflow的 WiX Tips and Tricks 帖子中的建议。此外,我的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>

3 个答案:

答案 0 :(得分:13)

这样的事情很可能会成功:

<MajorUpgrade AllowSameVersionUpgrades="yes"
          DowngradeErrorMessage="Can't downgrade."
          Schedule="afterInstallInitialize" />


<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>


<CustomAction Id="Overwrite_WixSetDefaultPerMachineFolder" Property="WixPerMachineFolder" Value="[ProgramFiles64Folder][ApplicationFolderName]" Execute="immediate" />
<InstallUISequence>
    <Custom Action="Overwrite_WixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
</InstallUISequence>
<InstallExecuteSequence>
    <Custom Action="Overwrite_WixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
</InstallExecuteSequence>

<SetProperty Id="ARPINSTALLLOCATION" Value="[APPLICATIONFOLDER]" After="CostFinalize" />

更新: SetDirectory安排WixSetDefaultPerMachineFolder之前的操作 - 针对手动排定的元素更新代码,以便在WixSetDefaultPerMachineFolderWixSetPerMachineFolder之间进行安排。在Win7 x64

下使用OP示例代码进行了测试

UPDATE2 :添加了将ARPINSTALLOCATION设置为http://robmensching.com/blog/posts/2011/1/14/ARPINSTALLLOCATION-and-how-to-set-it-with-the-WiX-toolset

的操作

答案 1 :(得分:6)

我不得不改变两件事来让WIX将我的64位应用程序放在Program Files文件夹中:

一个。在WIX Package元素中,添加'Platform =“x64”':

<包装说明=“desc ...” 制造商=“公司......”InstallerVersion =“200”平台=“x64”压缩=“是”/>

B中。在顶级文件夹的Directory元素中,将ProgramFilesFolder更改为ProgramFiles64Folder:

ProgramFiles64Folder ”Name =“PFiles”>

(我还必须包括<程序名称> 文件夹中的.exe.config文件,以使程序正常工作)

答案 2 :(得分:-1)

我认为您需要为其中一个节点将Win64属性设置为Yes