Passing an absolute path to a custom action in WiX
I am using WiX to create an installer for my app
I have this snippet that describes the destination folder for my application:
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="CommonAppDataFolder">
<Directory Id="Company" Name="myCompany">
<Directory Id="App" Name="myProgram">
<Directory Id="SQLGENERATORINSTALLFOLDER" Name="SqlLiteFolder" />
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
I also have a custom action that requires a folder as an input parameter [App]
. If I pass [App]
to a custom action I would expect the entire folder path starting at C: \ all the way down to an internal folder
I would expect this:
C: \ ProgramData \ mycomp \ MyProgram \
Instead, I get this:
C: \ Windows \ Installer \ MSI971.tmp-C: \ ProgramData \ mycomp \ MyProgram \
It looks like WiX is adding a temporary folder of some kind
EDIT
This is how I pass the variable [App]
to the custom action:
<CustomAction Id='GrantAccessToDatabase' BinaryKey='ActionLib' DllEntry='GrantAccess' Execute='deferred' Impersonate='no' />
<Property Id="GrantAccessToDatabase" Value="DbFilePath=[App]" />
Please note that in order to pass a variable to a deferred custom action I need to use this syntax, it is explained here -> How to pass parameters to a custom action?
This is the C # part that gets the parameter:
[CustomAction]
public static ActionResult GrantAccess(Session session)
{
var data = session.CustomActionData;
var fullPath = data["DbFilePath"];
}
I would expect fullPath
:
C: \ ProgramData \ mycomp \ MyProgram \
Instead, I get:
C: \ Windows \ Installer \ MSI971.tmp-C: \ ProgramData \ mycomp \ MyProgram \
source to share
No one has answered this question yet
See similar questions:
or similar: