views:

255

answers:

2

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='C7A5A70E-261C-11DF-9FB7-49AC56D89593'>
        <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?

+2  A: 

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 PROPERTY=VALUE C:\Example.msi

e.g. in your case

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

See the MSDN docs on using command line options with MSIEXEC

marc_s
That worked, only it has to be msiexec /i C:\Example.msi USERID=somevalue. If you set the property between the /i option and the filename (which is the option's argument), it won't install. Thanks for your help, that was much easier than I'd expected.
Mike Pateras
+1  A: 

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

Hightechrider