I'm trying to create an msi installer that will install the application to the console session's local app data directory, even when the session that runs the msi is the system session (when deploying via GPO).
For that, I'm creating a custom action that extracts the 'right' local app data directory (this code works, no issues there).
The custom action will set the value of a property called 'INSTALLDIR'.
This is the relevant code from the wxs:
<Property Id="INSTALLDIR" Value="C:\Users\default\AppData\Local\" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="INSTALLDIR">
<Directory Id="APPLICATIONFOLDER" Name="MyApp">
...
<Binary Id="MyCA" SourceFile="My.CustomActions.CA.dll"/>
<CustomAction Id="MyCASetLocalAppData" Impersonate="no" BinaryKey="MyCA" DllEntry="SetLocalAppData" Return="check" />
...
<InstallExecuteSequence>
<Custom Action="MyCASetLocalAppData" Before="CostFinalize">Not Installed OR UPGRADINGPRODUCTCODE</Custom>
In the install log, I can see the INSTALLDIR's value change from the initial value to the right value from the custom action, but later on in the log, the INSTALLDIR's value is the default value again.
It seems like I need to call the MyCASetLocalAppData multiple times...
How can I fix this?
Thanks!
I know that the docs say to schedule before CostFinalize
, but that might be too late. Try changing it to After="CostInitialize"
(which is when WiX's SetDirectory
element schedules it).