0

我正在使用 Wix 创建我的应用程序安装程序并使用它在 GAC 中安装程序集,它工作正常。

我的问题是当我设置程序集属性'copy local=false'并且我正在执行安装时,我的服务没有被安装,因为它在本地文件夹中找不到这个 dll 并且它没有被安装到广汽还。

如果我将从 EXE 安装中安装另一个组件并验证 DLL 是否在 GAC 中,我将能够安装该服务。

我正在使用 Paraffin.exe 遍历我的应用程序目录并生成一个 wix 文件,并使用 Mold 文件添加不是来自该目录的组件。

<DirectoryRef Id="Manager">
    <Component Id="NlogGACRegisterComponent" Guid="1B224CD1-6EE8-46D3-9335-A84B7D8FB87B">
        <File Id="NlogDLL" Name="Nlog.DLL" Source="..\Logging\Nlog.DLL"  KeyPath="yes" Vital="yes" Assembly=".net"/>   
    </Component>
    <Component Id="ManagerServiceComponent" Guid="EA31E161-4331-4A82-8F2B-7E26F62C96D6">
        <File Id="StateManagerServiceEXE" Name="ManagerHostService.exe" DiskId="1" Source="..\ManagerHostService.exe"  KeyPath="yes" Vital="yes" />
        <ServiceInstall Id="ServiceInstaller" Type="ownProcess" Name="ManagerHostService" DisplayName="Manager Service" Description="Manager Service" Start="auto"  Account="[SERVICEACCOUNT]" Password="[SERVICEPASSWORD]" ErrorControl="normal">
            <util:PermissionEx User="Everyone" GenericAll="yes" ServiceChangeConfig="yes" ServiceEnumerateDependents="yes" ChangePermission="yes" ServiceInterrogate="yes" ServicePauseContinue="yes" ServiceQueryConfig="yes" ServiceQueryStatus="yes" ServiceStart="yes" ServiceStop="yes" />
        </ServiceInstall>
        <ServiceControl Id="StartService" Start="install" Name="ManagerHostService" Stop="both" Remove="uninstall" Wait="yes" />
    </Component>
  </DirectoryRef>

这在负责将DLL安装到GAC然后服务的Mold文件中。

如何确保它先安装 DLL,然后再安装服务?

4

1 回答 1

2

在服务启动时,所有文件和 Dll 都已安装。在 InstallExecuteSequence 中使用 Orca 查看您的 MSI 文件(或查看详细日志),您会看到 InstallServices 和 StartServices 在 InstallFiles 之后。

问题是在 InstallFinalize 之前,程序集在 GAC 中未安装和可用,此处对此进行了描述:

https://msdn.microsoft.com/en-us/library/aa370063(v=vs.85).aspx

它说“这意味着您不能使用 ServiceControl 表来启动服务,而是必须使用在 InstallFinalize 之后排序的自定义操作。” 这是你需要做的。

于 2015-07-09T17:19:05.677 回答