[英]Is there a way to make a combined 32-bit and 64-bit installer in Wix?
[英]WiX: Prevent 32-bit installer from running on 64-bit Windows
由於用戶混淆,我們的應用程序需要單獨的安裝程序,用於32位和64位版本的Windows。 雖然32位安裝程序在win64上運行良好,但它有可能造成支持問題,我們希望防止這種情況發生。
我想阻止32位MSI安裝程序在64位Windows機器上運行。 為此,我有以下條件:
<Condition Message="You are attempting to run the 32-bit installer on a 64-bit version of Windows.">
<![CDATA[Msix64 AND (NOT Win64)]]>
</Condition>
使用Win64定義如下:
<?if $(var.Platform) = "x64"?>
<?define PlatformString = "64-bit"?>
<?define Win64 ?>
<?else?>
<?define PlatformString = "32-bit"?>
<?endif?>
事實是,我無法使這項檢查工作正常。 無論是一直開火,還是一無所有。 目標是檢查運行時msix64
變量對編譯時Win64
變量的存在,並拋出錯誤,如果這些不排隊,但邏輯不起作用我打算如何。 有沒有人想出更好的解決方案?
僅在您的32位軟件包中包含Condition元素(即,使用?if?預處理程序語句)。 條件將是“NOT Msix64”:啟動條件必須為true,因此如果設置了Msix64,則啟動條件將失敗,這意味着它是x64操作系統和32位軟件包,正確的做法是塊。
我們使用以下......
<?if $(var.ProcessorArchitecture)=x86 ?>
<Condition Message="!(loc.LaunchCondition_Error64)">
<![CDATA[Installed OR Not VersionNT64]]>
</Condition>
<?endif?>
condition元素適用於安裝期間存在的Windows安裝程序屬性。
但是,您將Win64
定義為wix變量,而不是Windows安裝程序屬性。 Wix變量僅在創建設置時存在。 您必須將它們作為$(var.MyWixVariable)
引用它們, $(var.MyWixVariable)
預處理器將用它們定義的值替換它們。
我會嘗試這樣做:
<?if $(var.Platform) = "x64"?>
<?define PlatformString = "64-bit"?>
<Property Id="Win64" Value="1" />
<?else?>
<?define PlatformString = "32-bit"?>
<?endif?>
如果$(var.Platform)
在創建安裝程序時具有正確的值,那么這將導致“Win64”屬性記錄在Windows安裝程序數據庫(即MSI文件)中,並且該屬性在安裝期間可用以供使用在條件元素中。
添加此條件
<Condition Message="This is designed for 32bit OS">%PROCESSOR_ARCHITECTURE ~= "x86" AND %PROCESSOR_ARCHITEW6432 <> "amd64"></Condition>
您可以使用32位組件和64位組件創建一個安裝程序,並將這兩個條件放在相應的組件中
<Component Id="bit32Component" Guid="..." Feature="ProductFeature">
<Condition>%PROCESSOR_ARCHITECTURE~="x86" AND %PROCESSOR_ARCHITEW6432<>"amd64"></Condition>
</Component>
<Component Id="bit64Component" Guid="..." Feature="ProductFeature">
<Condition>%PROCESSOR_ARCHITECTURE~="amd64" OR %PROCESSOR_ARCHITEW6432~="amd64"></Condition>
</Component>
這是我用過的參考文獻
http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.