3

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • +1 I know this question is old, but I have the same issue (updating a config file used by service). Marc, since the suggestion by Anton Tykhyy didn't solve this, you might consider removing the answer flag. The question will get more attention and I won't have to re-ask it. Just a thought. – Randy Eppinger Apr 22 '10 at 16:59

2 Answers2

1

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>
Community
  • 1
  • 1
Randy Eppinger
  • 1,054
  • 13
  • 23
1

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

Anton Tykhyy
  • 19,370
  • 5
  • 54
  • 56