2010-04-28 85 views
6

我有一個用C#編寫的應用程序,它依賴於sqlite託管提供程序。 sqlite提供程序是依賴於平臺的(對於32位和64位應用程序,有兩個同名的dll)。應用程序在運行時基於OS加載所需的一個。在一個Windows安裝程序中的32位和64位程序集

的問題是,雖然創建一個安裝程序我不能添加64位模式下的dll到安裝項目,因爲我收到以下錯誤:File '' targeting '' is not compatible with the project's target platform ''.

我會用其他的安裝程序,但我必須爲自定義操作在安裝過程中調用。

所以我想知道是否有一個安裝程序,它可以讓我添加32位和64位DLL,並執行用C#編寫的自定義操作。

一個可能的解決方案是有兩個安裝程序,但我希望儘可能避免它。

有什麼建議嗎?

回答

6

Inno Setup安裝程序支持您請求的功能,該安裝程序非常靈活可靠,在Web中存在許多腳本樣本,以根據最終客戶端的體系結構進行條件安裝。

檢查位於此腳本C:\Program Files\Inno Setup 5\Examples\64BitThreeArch.iss

-- 64BitThreeArch.iss -- 
; Demonstrates how to install a program built for three different 
; architectures (x86, x64, Itanium) using a single installer. 

; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES! 

[Setup] 
AppName=My Program 
AppVerName=My Program version 1.5 
DefaultDirName={pf}\My Program 
DefaultGroupName=My Program 
UninstallDisplayIcon={app}\MyProg.exe 
Compression=lzma2 
SolidCompression=yes 
OutputDir=userdocs:Inno Setup Examples Output 
; "ArchitecturesInstallIn64BitMode=x64 ia64" requests that the install 
; be done in "64-bit mode" on x64 & Itanium, meaning it should use the 
; native 64-bit Program Files directory and the 64-bit view of the 
; registry. On all other architectures it will install in "32-bit mode". 
ArchitecturesInstallIn64BitMode=x64 ia64 

[Files] 
; Install MyProg-x64.exe if running on x64, MyProg-IA64.exe if 
; running on Itanium, MyProg.exe otherwise. 
Source: "MyProg-x64.exe"; DestDir: "{app}"; DestName: "MyProg.exe"; Check: IsX64 
Source: "MyProg-IA64.exe"; DestDir: "{app}"; DestName: "MyProg.exe"; Check: IsIA64 
Source: "MyProg.exe"; DestDir: "{app}"; Check: IsOtherArch 
Source: "MyProg.chm"; DestDir: "{app}" 
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme 

[Icons] 
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe" 

[Code] 
function IsX64: Boolean; 
begin 
    Result := Is64BitInstallMode and (ProcessorArchitecture = paX64); 
end; 

function IsIA64: Boolean; 
begin 
    Result := Is64BitInstallMode and (ProcessorArchitecture = paIA64); 
end; 

function IsOtherArch: Boolean; 
begin 
    Result := not IsX64 and not IsIA64; 
end; 
1

使用Windows安裝程序,沒有。你需要兩個設置。

但是,NSIS能夠在運行時檢測的單個設置中處理兩個平臺。這真的取決於如果你的目標企業用戶與否,企業客戶將需要Windows Installer(MSI)的軟件包,而一般的互聯網用戶並不關心:)

1

我喜歡創新安裝的想法,我可能會放棄它是一個嘗試,但考慮以下幾點:

微軟MSI最佳實踐是有2個獨立的設置,一個爲32和一個爲64,許多第三方IDE像Installshield支持這些最佳實踐。國際海事組織可能有這個原因,否則他們會增加這個功能來超越競爭對手。

要從單個安裝項目創建2個安裝程序,您必須使用同一個安裝項目構建兩個安裝程序,使用發行標誌,基本上創建一個包含32位程序集的功能,另一個包含64位程序集,一個發佈標誌,並分別構建每個版本,

因此,在構建時,您構建了32位版本,它已打包,而64位被忽略,則您對64位也做同樣的事情。如果需要,您可以通過命令行參數傳遞這些標誌。

這樣你就沒有重複的設置代碼來維護。

1

Windows安裝程序工作正常,在這種情況下,例如有兩個組件,每個組件都有一個sqlite文件,並根據VersionNT64屬性有條件地安裝一個或另一個,該屬性僅在安裝在64位平臺上運行時設置。

相關問題