doctagre
doctagre

Reputation: 43

Set File Name to Property

I have a Merge Module which installs a file. I would like to use a property passed to the Merge Module during MSI creation. Something like:

<Configuration Name='FileNameProperty'
               Format='Text'
               DefaultValue='[FileNameProperty]' />

<Substitution Table='CustomAction'
              Row='SetFileName'
              Column='Target'
              Value='[=FileNameProperty]' />

<CustomAction Id='SetFileName'
              Property='MYFILENAME'
              Value='[MYFILENAME]' />

<InstallExecuteSequence>
  <Custom Action='SetFileName'
          Before='LaunchConditions'>1</Custom>
</InstallExecuteSequence>

...

<File Name="[MYFILENAME]"
      Source="my-file.exe" />

Currently I am using a Custom Action, namely Type 51, which works when substituting property values for other element attributes, such as ServiceInstall DisplayName. However, in this instance the file is deployed as [MYFILENAME].

I've looked through the other Custom Actions provided by MSDN, but can't find anything that fits this situation. Any suggestions or idea if this is even possible?

My last ditch option is to include File elements for each variation of file name and select the desired file based off condition, but I would like to avoid that.

Upvotes: 1

Views: 136

Answers (1)

Bob Arnson
Bob Arnson

Reputation: 21896

File names aren't formatted so properties can't be used. If you use multiple files, WiX's smart cabbing ensures the copies don't take up extra space in your cabinet.

Upvotes: 1

Related Questions