Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I find out the location from where the msi installer is being run

Tags:

wix

Can anyone tell me how can I find out the location from where the msi installer is being run.

For example I have my Sample.msi and Manuals folder in the folder InstallerExample on the Desktop.

I need this information so that I can use it in File/@Source, like the one given below.

<File Id="MyFileId" Name="MyFile" Source="[SourceDir]Manuals" KeyPath="yes" >

SourceDir should have value C:\Users\bla\Desktop\InstallerExample\Manuals

It will be great if anyone can please help me with this.

like image 703
sanam_bl Avatar asked Nov 03 '22 18:11

sanam_bl


1 Answers

I just had the same problem as I wanted my custom action to read a file from where my MSI was so i needed the path. I was able to locate it using

TARGETDIR

According to the MSDN documentation TARGETDIR is

the root destination directory for the installation

Also according to MSDN, SourceDir is

the root directory that contains the source cabinet file or the source file tree of the installation package

So the SourceDir property points to a real directory: the one where your MSI file sits. You can see this in the installer log when installing with msiexec /lvx* installer.log installer.msi.

However, for some reason SourceDir is completely ignored when resolving the TARGETDIR. The TARGETDIR must be either set explicitly (e.g. on the command line) or else it resolves to ROOTDRIVE. If ROOTDRIVE is not explicitly set then it is the root of the drive with the most free space.

like image 155
Natalie Carr Avatar answered Jan 04 '23 13:01

Natalie Carr