0

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?

chen
  • 131
  • 1
  • 1
  • 11

1 Answers1

2

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.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • That means I have to add a .bat script to run my service and run it in the CustomAction after installation is done, correct? I did that and it works but isn't there a way to prevant from running a script and just use some Wix Element to run my service once the installation is finish? – chen Jul 13 '15 at 07:52
  • Doesn't need to be a bat file if you can write a few lines of VBScripr or C++. and run as a custom action, called from the Binary table. – PhilDW Jul 13 '15 at 19:12
  • That means I need to add the VBScript to one of my projects and then run this function with BinaryKey as you suggest, correct? I'm looking for a way to run the service from WIX without adding files\code if that's possible? – chen Jul 14 '15 at 09:37