title: MSI install sequence - run DB scripts before services start
body: <p>Folks,</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Right now, our custom action to run the database updater looks like this - it's being run after "InstallFinalize" - very late in the process.</p>
  
  <pre><code>   &lt;InstallExecuteSequence&gt;
        &lt;RemoveExistingProducts After='InstallInitialize' /&gt;
        &lt;Custom Action='RunDbUpdateManagerAction' After='InstallFinalize'&gt;
             DbUpdateManager=3&lt;/Custom&gt;
     &lt;/InstallExecuteSequence&gt;
  </code></pre>
  
  <p>What would be the more appropriate step to run after or before, to make sure the DB scripts are executed <em>before</em> any of the installed services start up? Is there a "BeforeServiceStart" step? </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Just defining the "Before='StartServices'" attribute on the  tag didn't solve my problem.</p>
  
  <p>I am assuming the issue is this: the custom action has an "inner text", which represents a condition, and this condition is:  "&amp;DbUpdateManager=3". From what I can deduce from trial &amp; error, this probably means "the DbUpdateManager feature must be published".</p>
  
  <p>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 :-(</p>
  
  <p>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.....</p>
  
  <p>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??</p>
  
  <p>Marc</p>