This question already has answers here:
Closed 3 years ago.
In wix projects you will generally see a line like
<Directory Id="TARGETDIR" name="SourceDir">
But why does the name
need to be set here? From what I understand the name
property specifies the name of the generated folder on the machine doing the installing. But no SourceDir folder will be created, so why is it needed?
UPDATE:
It turns out this question has been asked before. Check this post for an explanation from Wix creator Rob Mensching: In WiX files, what does Name="SourceDir" refer to?
TARGETDIR plays a special role in the resolution of an MSI file's Directory table. Specifically it forms the root of the source and target directory trees. This is indicated in the MSI file by the null value in the Directory_Parent column:
After directory resolution SourceDir will point to the path where the MSI is running from. Furthermore TARGETDIR will be the parent folder for most built-in Windows directories such as ProgramFilesFolder and ProgramMenuFolder as illustrated in the image above.
So in short SourceDir is defined to hold the location of the running MSI file, and this location is necessary to know in order to resolve the source locations on the distribution media for each file to install.
A target location is a full installation path for a file: C:\Program Files\My App (where the file is going). A source location is the full source path for a file: [SourceDir]Program Files\My App (where the file is coming from).
It is late, please let me know if this wasn't clear.