2011-03-29 60 views
11

我使用WixUI_Advanced序列,以允許用戶隨到隨每臺機器每個用戶安裝和更改目標文件夾。我的WiX項目旨在生產x86x64 MSI(我正在使用WiX Tips and Tricks建議)。我還將重要升級(我使用APPLICATIONFOLDER屬性和目錄ID - 而不是INSTALLLOCATION - 根據WixUI_Advanced要求)的應用程序安裝文件夾保存在註冊表中。WiX:如何在WixUI_Advanced序列中覆蓋x64機器上的「C: Program Files(x86)」?

有一個bug in WixUI_Advanced sequence引起目標文件夾對話框下C到顯示該應用文件夾:\程序文件(x86)代替C:\ Program Files文件 64位機器上運行時,即使當代碼正確設置應用程序文件夾爲ProgramFiles64Folder屬性。錯誤跟蹤器註釋建議使用SetDirectory元素來設置APPLICATIONFOLDER的值,但有沒有示例解釋如何執行此操作。當我嘗試時,它確實有點改變(我還發現一些推薦使用自定義操作來設置APPLICATIONFOLDER的帖子,但沒有一個適合我)。有誰知道如何在64位系統上使WixUI_Advanced序列顯示正確的「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> 

非常感謝薩沙博蒙特解決這個問題下面是工作樣例:

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

回答

9

像這樣的事情可能會做的伎倆:

<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時間表之前WixSetDefaultPerMachineFolder的動作 - 代碼更新的手動調度元素WixSetDefaultPerMachineFolderWixSetPerMachineFolder之間安排。在Win7的X64測試了OP的示例代碼OK

UPDATE2:添加動作設置ARPINSTALLOCATIONhttp://robmensching.com/blog/posts/2011/1/14/ARPINSTALLLOCATION-and-how-to-set-it-with-the-WiX-toolset

+0

謝謝Sascha,但它似乎沒有工作。我更新了文章以包含完整的WXS文件示例(它安裝位於項目文件夾中的單個Readme.txt文件)。當我在64位Windows 2008 Server上運行它時,「目標文件夾」對話框仍然指向Program Files(x86)文件夾。代碼有什麼問題嗎? – 2011-03-30 20:35:30

+0

嗨阿列克,看到更新的帖子 - 這對我來說在Win7 x64上5分鐘冒煙測試:) – saschabeaumont 2011-04-07 04:10:53

+0

甜!看起來像是在工作。謝謝,Sascha! – 2011-04-07 20:15:26

0

我認爲你需要設置Win64屬性Yes的節點之一。

+1

它已被設置爲Win64 =「是」所有組件(對於x64版本)。 – 2011-03-30 04:18:57

6

我不得不改變兩件事情,使維克斯把我的64位應用程序在Program Files文件夾:

A.在維克斯包元素中,添加「平臺=‘64’」:

&lsaquo; Package Description =「desc ...「 製造商=」 公司......」 InstallerVersion = 「200」 平臺= 「64」壓縮= 「是」/&rsaquo;

B.在爲頂級文件夾的目錄元素,改變ProgramFilesFolder到ProgramFiles64Folder:

&lsaquo;上目錄的編號= 「ProgramFiles64Folder 」NAME =「 PFILES」 &rsaquo;

(我還必須包括與lsaquo;上節目名稱&rsaquo;該文件夾中 .exe.config文件與該程序工作正常)

+0

使用OP規定的WixUI_Advanced時,這不起作用。 – 2015-07-02 17:14:34

相關問題