We're struggling with a problem, and I'm curious if anyone has any
creative solutions they can think of.

We have a windows service that our MSI installs.  This service does some
things with MSMQ.  We want to ensure that our service has the
appropriate ServiceDependency so that Windows starts things in the
correct order during system startup.

Our WiX structure looks something like this (attributes removed to
simplify):

<Component>
  <File/>
  <ServiceInstall>
    <ServiceConfig/>
    <ServiceDependency Id="MSMQ"/>
    <ServiceDependency Id="Eventlog"/>
  </ServiceInstall>
  <ServiceControl/>
</Component>

Now, in the next version of our product, the MSMQ related functionality
is optional and we will have many customers who will not need or care
about the MSMQ functionality.  We'd like to detect if MSMQ is installed
and make sure that the service is installed with the MSMQ dependency
only if MSMQ is installed (else the service won't start when MSMQ is not
installed).

The first attempt to accomplish this with WiX was to have two nearly
identical components and use conditions to choose only the correct one:

<Component>
  <File/>
  <ServiceInstall>
    <ServiceConfig/>
    <ServiceDependency Id="MSMQ"/>
    <ServiceDependency Id="Eventlog"/>
  </ServiceInstall>
  <ServiceControl/>
  <Condition>MSMQ_IS_INSTALLED</Condition>
</Component>
<Component>
  <File/>
  <ServiceInstall>
    <ServiceConfig/>
    <ServiceDependency Id="Eventlog"/>
  </ServiceInstall>
  <ServiceControl/>
  <Condition>NOT MSMQ_IS_INSTALLED</Condition>
</Component>

This doesn't work (in WiX v2) because of the <ServiceConfig/>.  We use
ServiceConfig to set the restart options correctly. WiX tries to put two
rows in the ServiceConfig table both with the same ServiceName.  This
fails because ServiceName is the primary key and the second row errors
out as a duplicate.

So, the next attempt was to move the ServiceConfig element to a
separate, shared Component that would always get installed regardless of
if MSMQ was needed or not.  This compiles into an MSI but fails at
install time because the NewService column in the ServiceConfig table is
set to 0 and the SchedServiceConfig custom action has code to verify
that the service actually exists and this check runs before the
installations script is executed (and so the service hasn't been
installed yet).

I don't like any of the options we're currently exploring, so I'm
looking for any brainstorming ideas.

Options we're currently looking at:

1. Using <CustomTable> to add the ServiceConfig table with the single
row we need and with NewService set to 1 and adding SchedServiceConfig
to the sequence ourselves.  Yuck.

2. Dropping the dependency from the ServiceInstall completely and adding
a custom action to conditionally call sc.exe to add the dependency back
if MSMQ is installed.  Bleh.

3. Dropping the dependency from the ServiceInstall completely and adding
code to our service itself so that when it starts up, it ensures that
MSMQ is running and attempt to start it if it isn't already running.
Windows won't know that our service depends on MSMQ, but we'll try to
replicate the logic that Windows would have used.  Bummer.

Any other suggestions?  Note, we haven't looked at WiX v3 yet (that's on
my list for today) to see if there is some new way around this issue
there.

Thanks,
Erv

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to