WiX:如何覆盖“C:\Program Files (x86)"在 WixUI_Advanced 序列中的 x64 机器上? [英] WiX: How to override "C:\Program Files (x86)" on x64 machine in WixUI_Advanced sequence?

查看:32
本文介绍了WiX:如何覆盖“C:\Program Files (x86)"在 WixUI_Advanced 序列中的 x64 机器上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WixUI_Advanced 序列来允许用户选择 每台机器每用户 安装并更改目标文件夹.我的 WiX 项目旨在生成 x86x64 MSI(我使用的是 WiX 技巧和窍门 建议).我还将应用安装文件夹保存在注册表中以进行重大升级(我使用 APPLICATIONFOLDER 属性和目录 ID -- 而不是 INSTALLLOCATION -- 根据 WixUI_Advanced 要求).

I'm using WixUI_Advanced sequence to allow users pick per-machine or per-user installation and change destination folder. My WiX project is intended to produce both x86 and x64 MSIs (I'm using WiX Tips and Tricks recommendations). I also keep the app installation folder in the registry for major upgrades (I use APPLICATIONFOLDER property and directory ID -- instead of INSTALLLOCATION -- per WixUI_Advanced requirements).

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

There is a bug in WixUI_Advanced sequence that causes the Destination Folder dialog to display the app folder under C:\Program Files (x86) instead of C:\Program Files when running on a 64-bit machine, even when the code correctly sets app folder to ProgramFiles64Folder property. The bug tracker comment suggests using the SetDirectory element to set the value of APPLICATIONFOLDER, but there is no example explaining how to do this. When I tried, it did dot make any difference (I also found a number of posts recommending using a custom action to set APPLICATIONFOLDER, but none worked for me). Does anyone know how to make WixUI_Advanced sequence display correct 'Program Files' folder on a 64-bit system (and also show the originally selected folder during major upgrades)?

如果有帮助,我将提供示例 WXS 片段,但它们几乎遵循 StackOverflow 的建议WiX 提示和技巧 发布.此外,我的 64 位 MSI 包确实是一个 64 位包(我将包和组件标记为x64";它不能在 32 位平台上运行.我使用的是 WiX 3.6 和 Visual Studio 2010.

If it helps, I'll provide sample WXS snippets, but they pretty much follow the recommendations from the StackOverflow's WiX Tips and Tricks post. Also, my 64-bit MSI package is indeed a 64-bit package (I have the package and components marked as 'x64"; and it does not run on 32-bit platforms). I'm using WiX 3.6 and 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 解决了这个问题.这是工作示例:

Many thanks to Sascha Beaumont for solving this problem. Here is the working sample:

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

推荐答案

这样的事情可能会奏效:

Something like this would probably do the trick:

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

更新: SetDirectoryWixSetDefaultPerMachineFolder 之前安排操作 - 为手动安排的元素更新了代码,以便在 WixSetDefaultPerMachineFolder 之间安排> 和 WixSetPerMachineFolder.在Win7 x64下用OP示例代码测试OK

UPDATE: SetDirectory schedules the action prior to WixSetDefaultPerMachineFolder - code updated for manually scheduled elements to schedule between WixSetDefaultPerMachineFolder and WixSetPerMachineFolder. Tested OK with OP sample code under Win7 x64

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

UPDATE2: Added action to set ARPINSTALLOCATION as http://robmensching.com/blog/posts/2011/1/14/ARPINSTALLLOCATION-and-how-to-set-it-with-the-WiX-toolset

这篇关于WiX:如何覆盖“C:\Program Files (x86)"在 WixUI_Advanced 序列中的 x64 机器上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆