Search code examples
custom-actionwix3.7

Install components before custom actions


My setup app should create user in sql server and restore a database. I do it as two separate projects;one to copy the database backup file to the machine, and the other one to do the actions. I'm planning to make it a single project.

  <Fragment>  
    <Directory Id="TARGETDIR" Name="SourceDir">      
       <Directory Id="ProgramFiles64Folder" Name="Program Files"  >
          <Directory Id="INSTALLFOLDER" Name="My Produact name" >
            <Directory Id="DBDIR" Name="DB PreReq"  ></Directory>
          </Directory>
       </Directory>
    </Directory>

    <UI Id="DbConfigSetupUI"  >      
      <TextStyle Id="DlgFont8" FaceName="Tahoma" Size="8" ></TextStyle>
      <TextStyle Id="DlgTitleFont" FaceName="Tahoma" Size="8" Bold="yes" ></TextStyle>
      <UIRef Id="Custom_WixUI_Mondo" />      
      <UIRef Id="WixUI_ErrorProgressText" />
      <InstallUISequence >               
          <Custom Action="CreateUserWithSa"  Before="FileCost"  >NOT Installed</Custom>          
          <Custom Action="CreateUserWithWindows" After="CreateUserWithSa"  >(SARETURN="fail") AND NOT Installed</Custom>
          <Show   Dialog="ConnectionStringDialog" After="CreateUserWithWindows"   >(WINDOWSRETURN="fail") AND NOT Installed</Show>
          <Custom Action="CreateUserWithPrompt"  After="ConnectionStringDialog" >(DBLOGIN AND PASSWORD) AND NOT Installed</Custom>        
          <Custom Action="CreateDB"  After="CreateUserWithPrompt" >(SARETURN="pass" OR WINDOWSRETURN="pass" OR PROMPTRETURN="pass") AND NOT Installed</Custom>        
      </InstallUISequence>      
    </UI>
  </Fragment>

Here the files are not being copied(components are placed in a separate file), but the custom actions are being done. Since the backup file is necessary to restore. I need that to happen first. Is there a way to achieve that?


Solution

  • Schedule your custom action to run after InstallFinalize in the InstallExecuteSequence. You are guaranteed that your files will be installed by that point. Be warned you will need to store your property/data values if your action needs to access them.