簡體   English   中英

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

[英]WiX: How to override “C:\Program Files (x86)” on x64 machine in WixUI_Advanced sequence?

我正在使用WixUI_Advanced序列來允許用戶選擇每台機器每用戶安裝並更改目標文件夾。 我的WiX項目旨在生產x86x64 MSI(我正在使用WiX提示和技巧建議)。 我還將應用程序安裝文件夾保留在注冊表中以進行主要升級(我使用APPLICATIONFOLDER屬性和目錄ID - 而不是INSTALLLOCATION - 根據WixUI_Advanced要求)。

WixUI_Advanced序列中存在一個錯誤 ,導致目標文件夾對話框在64位計算機上運行時在C:\\ Program Files(x86)下顯示app文件夾而不是C:\\ Program Files ,即使代碼正確設置了app文件夾到ProgramFiles64Folder屬性。 錯誤跟蹤器注釋建議使用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>

像這樣的東西可能會成功:

<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的操作

我不得不改變兩件事來讓WIX將我的64位應用程序放在Program Files文件夾中:

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

<Package Description =“desc ...”Manufacturer =“company ...”InstallerVersion =“200” Platform =“x64” Compressed =“yes”/>

B.在頂級文件夾的Directory元素中,將ProgramFilesFolder更改為ProgramFiles64Folder:

<Directory Id =“ ProgramFiles64Folder ”Name =“PFiles”>

(我還必須在文件夾中包含<program name> .exe.config文件才能使程序正常工作)

我認為您需要為其中一個節點將Win64屬性設置為Yes

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM