Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the location of a file in a WiX Script

How do I make a custom action that references a file on the command line?

I have the custom action accessing the MYSQL properties correctly, but I haven't figured out the incantation to access the path to the installed sql script.

Below are the relevant sections of the WiX script. I am trying to get the custom action to reference the path to MYSQL_SCRIPTS file.

<Directory Id="TARGETDIR" Name="SourceDir">
   <Directory Id="ProgramFilesFolder">
   <Directory Id="INSTALLLOCATION" Name="MyProgram">
     <Directory Id="DbSetupDir" Name="DbSetup">
        <Component Id="SqlScripts" Guid="MYGUID">
           <File Id="MYSQL_EXE" Source="mysql.exe" Vital="yes" />
           <File Id="MYSQL_SCRIPTS" Source="MYSQL_SCRIPTS.sql" Vital="yes" />
        </Component>
     </Directory>
   </Directory>
 </Directory>

 ...

<CustomAction Id='LaunchFile' 
  FileKey='MYSQL_EXE'
  ExeCommand='--host=[MYSQL_SERVER]
  -u [MYSQL_USERNAME]
  -P [MYSQL_PORT]
  --password=[MYSQL_PASSWORD]
  -e [DbSetupDir]\ALS_Scripts.sql' 
  Return='check'/>
like image 343
Adam Tegen Avatar asked Nov 21 '25 01:11

Adam Tegen


1 Answers

Use the [#MYSQL_SCRIPTS] conversion, this will translate to the full path of those files at setup time.

<CustomAction Id='LaunchFile' 
  FileKey='MYSQL_EXE'
  ExeCommand='--host=[MYSQL_SERVER]
  -u [MYSQL_USERNAME]
  -P [MYSQL_PORT]
  --password=[MYSQL_PASSWORD]
  -e [#MYSQL_SCRIPTS]' 
  Return='check'/>
like image 174
Shay Erlichmen Avatar answered Nov 23 '25 15:11

Shay Erlichmen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!