Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX: How can I set a property externally?

In my WiX installer, I've got a property for a UserID that gets written to a registry key:

<Property Id='UserID' Value='123' />

<Directory Id='TARGETDIR' Name='SourceDir'>
    <Component Id='UserIDComponent' Guid='*'>
        <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' 
                       Type='integer' Value='[UserID]' Name='UserID' />
    </Component>

I'd like to set the value of that property to the User ID of the person downloading my installer on the fly. So when they go to download, I'll just create a copy of the base MSI that everyone gets, set the value of UserID to that of the person downloading the file, and that's what they download. It'll be the same installation package that everyone gets, but with the property custom set for them.

I can't seem to find any resources on how to set a WiX MSI property from an external source, though. How can I do this?

like image 633
Mike Pateras Avatar asked Mar 02 '10 17:03

Mike Pateras


2 Answers

Your options appear to be:-

(i) command line parameters on msiexec as per the other answer - fragile, not really an option if they are downloading and running it

(ii) attempt to hack the MSI file to insert the ID - a hack

(iii) launch MSBUILD to create a new MSI file on-demand on the server after modifying a copy of the WIX file to include their ID

(iv) pre-generate lots of MSI files with random IDs (GUIDs perhaps) in them and then associate those IDs with user IDs at download time in your database. Now provide a lookup service to map the random ID in the MSI file with the real user ID so that the program when it runs can find the user ID (or have a custom action that does this).

(v) create a custom action and use MsiGetProperty to get the filename of the installer - simply append the userID to the MSI file name - fragile hack

like image 37
Ian Mercer Avatar answered Dec 14 '22 06:12

Ian Mercer


As far as I remember, you can indeed set properties from the "outside" - the property name has to be in all UPPERCASE to be recognized as a public property (don't ask me why....) and then you can set it like this:

msiexec /i C:\Example.msi PROPERTY=VALUE

e.g. in your case

msiexec /i C:\Example.msi USERID=somevalue

See the MSDN docs on using command line options with MSIEXEC

like image 150
marc_s Avatar answered Dec 14 '22 04:12

marc_s