views:

470

answers:

2

Folks,

we're running into some sequencing troubles with our MSI install. As part of our app, we install a bunch of services and allow the user to pick whether to start them right away or later.

When they start right away, they seem to start too early in the install sequence - before our database manager had a chance to update the database.

Right now, our custom action to run the database updater looks like this - it's being run after "InstallFinalize" - very late in the process.

   <InstallExecuteSequence>
      <RemoveExistingProducts After='InstallInitialize' />
      <Custom Action='RunDbUpdateManagerAction' After='InstallFinalize'>
           DbUpdateManager=3</Custom>
   </InstallExecuteSequence>

What would be the more appropriate step to run after or before, to make sure the DB scripts are executed before any of the installed services start up? Is there a "BeforeServiceStart" step?

EDIT:

Just defining the "Before='StartServices'" attribute on the tag didn't solve my problem.

I am assuming the issue is this: the custom action has an "inner text", which represents a condition, and this condition is: "&DbUpdateManager=3". From what I can deduce from trial & error, this probably means "the DbUpdateManager feature must be published".

Now, trouble is: "PublishFeature" comes way at the end in the install sequence, just before "InstallFinalize", and definitely AFTER InstallServices / StartServices. So when I specify the "Before=StartServices" requirement, the condition "DbUpdateManager feature must be published" isn't true yet, so the DbUpdateManager doesn't get executed :-(

I tried removing the condition - in that case, my DbUpdateManager sometimes doesn't execute at all, sometimes more than once - no real clear pattern as to what happens when.....

Any more ideas?? Is there a way I could check for a condition "the DbUpdateManager feature is installed" which would be true after the "InstallFiles" step??

Marc

+1  A: 

There is no BeforeServiceStart, but you could try Before='StartServices'.

Anton Tykhyy
Looks promising - I'll give it a try tomorrow at the office and get back to you - thanks!
marc_s
Full reference of standard actions: http://msdn.microsoft.com/en-us/library/aa372023(VS.85).aspx
Wim Coenen
+1  A: 

Well, it appears that marc_s got this answered in another question. However, since my solution was slightly different and the other question requires a bit of reconstruction to get a solution, here is exactly what worked for me:

...
<InstallExecuteSequence>
  <Custom Action="CopyConfigs" 
          After="InstallFiles"><![CDATA[&ProductFeature = 3]]></Custom>
</InstallExecuteSequence>
<CustomAction Id="CopyConfigs"
              FileKey="copySamples"
              ExeCommand=""
              Execute="deferred"
              Impersonate="no"/>

<Directory Id="TARGETDIR" Name="SourceDir">
...
  <Directory Id="Config" Name="Config">
    <Component Id="ShippedConfigs" Guid="{8E6344C8-2B3F-4654-8B42-C09E76200052}">
      <File Id="copySamples"
            Source="$(var.ProjectDir)config\Copy.Configs.Sample.cmd"
            KeyPath="no"
            DiskId="1" />
    </Component>
  </Directory>
</Directory>

<Feature Id="ProductFeature" Title="MyService" Level="1">
  <ComponentRef Id="ShippedConfigs" />
  ...
</Feature>
Randy Eppinger

related questions