Reputation: 34632
I am copying a file to a directory, and then setting an environment variable to point to that file. This is working, however, I have to hard code the name of the file (I can't reuse what I already have). Here is the example:
<Directory Id="CUSTOM_DIRECTORY" Name="Directory">
<Component Id="Framework" Guid="YOURGUIDIDHERE">
<File Id="FrameworkJAR" Name="framework.jar" DiskId="1" Source="framework.jar" KeyPath="yes" />
<Environment Id="FrameworkVar" Name="CLASSPATH" Action="set" Permanent="no" Part="last" System="yes" Value="[CUSTOM_DIRECTORY]framework.jar" />
</Component>
</Component>
</Directory>
As you can see, in the Value attribute, I can type [CUSTOM_DIRECTORY] which will give me the full path of the directory, but I still have to manually type out framework.jar. Is it possible to just use something like Value="[FrameworkJAR]" to get the full install path of the JAR file?
Thank you.
Upvotes: 3
Views: 1439
Reputation: 22406
Yes, it is :)
See the documentation on the Formatted data type. Simply use...
Value="[#FrameworkJAR]"
From the documentation:
... If a substring of the form [#filekey] is found, it is replaced by the full path of the file, with the value filekey used as a key into the File table. The value of [#filekey] remains blank and is not replaced by a path until the installer runs the CostInitialize action, FileCost action, and CostFinalize action. ...
Upvotes: 3