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

发布于 2024-10-28 17:08:56 字数 6182 浏览 1 评论 0 原文

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

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

如果有帮助,我将提供示例 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>

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

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

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.

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

</Product>
</Wix>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

赠佳期 2024-11-04 17:08:56

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

<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 示例代码测试正常

更新2:添加了将ARPINSTALLOCATION设置为http://robmensching.com/blog/posts/2011/1/14/ARPINSTALLLOCATION-and-how-to -使用 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" />

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: Added action to set ARPINSTALLOCATION as http://robmensching.com/blog/posts/2011/1/14/ARPINSTALLLOCATION-and-how-to-set-it-with-the-WiX-toolset

笑梦风尘 2024-11-04 17:08:56

我必须更改两件事才能使 WIX 将我的 64 位应用程序放入 Program Files 文件夹中:

A. 在 WIX Package 元素中,添加 'Platform="x64"':

Platform="x64" Compressed="yes" /›

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

‹Directory Id="ProgramFiles64Folder" Name="PFiles"›

(我还必须包含<程序名称>
文件夹中的.exe.config文件以使程序正常运行)

I had to change two things to make WIX put my 64-bit app in the Program Files folder:

A. In the WIX Package element, add 'Platform="x64"':

‹Package Description="desc..."
Manufacturer="company..." InstallerVersion="200" Platform="x64" Compressed="yes" /›

B. In the Directory element for the top folder, change ProgramFilesFolder to ProgramFiles64Folder:

‹Directory Id="ProgramFiles64Folder" Name="PFiles"›

(I also had to include the ‹program name›
.exe.config file in the folder for the program to work correctly)

又爬满兰若 2024-11-04 17:08:56

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

I think you need to set the Win64 property to Yes for one of the nodes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文