简体   繁体   中英

How to wait for a file being installed to GAC before installing a service with wix

I'm using Wix to create my application installer and using it to install an assembly in the GAC and it works fine.

My issue is when I'm setting the assembly property 'copy local=false' and I'm executing the installation, then my services is not being installed cause it can't find this dll in the local folder and it's not being installed to GAC yet.

If I'll install another component from the EXE installation and will verify that the DLL is in the GAC I will be able then to install the service.

I'm using Paraffin.exe to go all over my application directory and generate a wix file and also using Mold file to add component not from this directory.

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

This in the Mold file which responsible to install the DLL to GAC and then the service.

How can I make sure it first install the DLL's and then the service?

All files and Dlls ARE installed by the time that services are started. Look in your MSI file with Orca at the InstallExecuteSequence (or look in a verbose log) and you'll see that InstallServices and StartServices are after InstallFiles.

The issue is that assemblies aren't installed and available in the GAC until InstallFinalize, this is described here:

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

where it says "This means you cannot use the ServiceControl Table to start the service, instead you must use a custom action that is sequenced after InstallFinalize." which is what you'll need to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM