I'm working on adding a feature to our WIX-based installer. It's my first time working with WIX so it's all quite new to me.
What I'm trying to do is allow users to pass an auth token command line argument when using msiexec
.
The installer will then make an API call with the auth token. If the auth fails, the installer will terminate. Otherwise, the installer will download a file using the API and copy it over to the install directory (most likely under Program Files
).
I've managed to read in the command line arguments as properties in WIX and have created a CustomAction in C# to handle the authentication / downloading the file.
The part I'm struggling with is getting the CustomAction to copy the file into the install location, as it doesn't have privileges to write to the location.
I can have it run with elevated privileges by setting execute="deffered"
and "impersonate=no
however that prevents me from reading in properties from the session
object.
Another possible option is to save the file to a temp location in the CustomAction (which works without elevated privileges) and set a new property. Then I can use the CopyFile
component with SourceProperty
to copy that file to the target location.
I'm unable to figure out, however, how to get the CustomAction to run before the CopyFile
component, as the property wouldn't be set until after the CustomAction has been run. Is it as simple as simply running running the CustomAction before
a specific part of the install, or is there more to it?