I'm using WiX to create an installer for my application
I have this fragment which describes the destination install 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 which requires the [App]
folder as an input parameter. If I pass [App]
to the custom action I would expect the entire path of the folder, from C:\ all the way down to the inner folder
I would expect this:
C:\ProgramData\myCompany\myProgram\
Instead, I get this:
C:\Windows\Installer\MSI971.tmp-C:\ProgramData\myCompany\myProgram\
Looks like WiX is appending a temporary folder of some sort
EDIT
This is how I pass the [App]
variable 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 that syntax, it's explained here -> How to pass parameters to the custom action?
That's the C# part which receive the parameter:
[CustomAction]
public static ActionResult GrantAccess(Session session)
{
var data = session.CustomActionData;
var fullPath = data["DbFilePath"];
}
I would expect fullPath
to be:
C:\ProgramData\myCompany\myProgram\
Instead, I get:
C:\Windows\Installer\MSI971.tmp-C:\ProgramData\myCompany\myProgram\
Most cases, your installer is cached hence the temporary folder. You can instead concatenate the full path: <...Value="DbFilePath=[CommonAppDataFolder]\myCompany\myProgram" />
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With