代码之家  ›  专栏  ›  技术社区  ›  Giorgi

一个Windows Installer中的32位和64位程序集

  •  6
  • Giorgi  · 技术社区  · 16 年前

    我有一个用C编写的应用程序,它依赖于SQLite管理的提供程序。sqlite提供程序依赖于平台(对于同名的32位和64位应用程序,有两个DLL)。应用程序在运行时基于OS加载所需的一个。

    问题是,在创建安装程序时,无法将64位模式dll添加到安装项目中,因为出现以下错误: File '' targeting '' is not compatible with the project's target platform ''.

    我将使用其他安装程序,但我有一个自定义操作,必须在安装过程中调用该操作。

    所以我想知道是否有一个安装程序可以让我添加32位和64位的DLL到它并执行用C编写的自定义操作。

    一个可能的解决方案是有两个安装程序,但如果可能的话,我想避免安装。

    有什么建议吗?

    4 回复  |  直到 13 年前
        1
  •  6
  •   RRUZ    16 年前

    这个 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;
    
        2
  •  1
  •   saschabeaumont    16 年前

    使用Windows Installer,不需要。您需要两个设置。

    然而 NSIS 能够在运行时检测的单个设置中处理两个平台。这取决于您是否瞄准企业用户,企业客户将需要Windows Installer(MSI)软件包,而您的普通互联网用户并不关心:)

        3
  •  1
  •   GenEric35    16 年前

    我喜欢Inno设置的想法,我可能会尝试一下,但请考虑以下几点:

    Microsoft MSI的最佳实践是有两个独立的设置,一个用于32,一个用于64,许多第三方IDE(如InstallShield)支持这些最佳实践。IMO可能是有原因的,否则他们会添加此功能,以超越竞争对手。

    要从一个安装项目中构建两个安装程序,您可以让两个安装程序都从同一个安装项目中构建,使用发布标志,基本上创建一个包含32位程序集的功能,另一个包含64位程序集的功能,为每个功能分配一个发布标志,并分别构建每个版本,

    所以在构建时,您构建32位版本,它是打包的,而64位被忽略,然后您对64位执行相同的操作。如果需要,可以通过命令行参数传递这些标志。

    这样您就没有要维护的重复设置代码了。

        4
  •  1
  •   Rory    13 年前

    Windows Installer在这种情况下工作正常,例如,有两个组件,每个组件带有一个sqlite文件,并根据versionnt64属性有条件地安装一个或另一个组件,该属性仅在安装在64位平台上运行时设置。

    推荐文章