In my wxi file, I want to set a variable that has the Program Files directory. I want it to pick the localized value of Program Files.
<?define MyDirectory="!(wix.LocalizedProgramFilesFolder)\MyFiles"?>
I have defined LocalizedProgramFilesFolder as:
<WixVariable Id="LocalizedProgramFilesFolder" Value="[ProgramFilesFolder]"/>
However during installation the MyDirectoryis picked as:
"[ProgramFilesFolder]\MyFiles".
It does not expand ProgramFilesFolder. How do I use ProgramFilesFolder value in a variable in my wxi file?
Not sure why you are using a MyDirectory
variable. As the WixVariable docs say:
WiX variables do not persist into the msi/msm/pcp file, so they cannot be used when an MSI file is being installed; it's a WiX-only concept.
Its value is written as text into wherever you use it. So, if you want the value to have properties substituted at install-time, you must use it only in such a context.
Typical usage of ProgramFilesFolder is as a Directory/@Id, which can have a descendant Directory, such as MyFiles
. Note: a Directory/@Id is also a property so it can be used as such.
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="MyFiles" />
</Directory>
</Directory>
INSTALLFOLDER
is used instead of MyDirectory
. You can use whatever you want but that the default from the project template. It is all caps, which makes it a public property. A public property value can be passed into the installer sequence from the UI or using msiexec
or other programs, such a bootstrappers.