WIX installer getting SourceDir?

Soldato
Joined
16 Jun 2013
Posts
5,375
I'm hoping someone here can help me before I venture into the unforgiving lands of stackoverflow.

Basically I have a folder included in a .rar file with the .msi that I need to copy to the target directory(licence requirements means I can't include it in project :mad:).

I've happily got the copy function going with a hard coded path but obviously this isn't going to work on users machines.

From googling I get the impression that I can use "$(var.SourceDir)\MyFolder" however this returns a "undefined preprocessor variable" error.

Googling again leads me to dead ends of people wanting to hard code the SourceDir so I am at a complete loss :(.

Any ideas? Am I barking up the wrong tree here?

(I have a grand total of 3 hours of WIX experience so I'm struggling a bit. Just need to get this sorted and the installer is done:(.)
 
Last edited:
Seeing as how OcUK ranks pretty highly in search just in case some other person has the same problem as me;

Set SourceDir as a registry key;

<ComponentGroup Id="RegSetMsiPath" Directory="TARGETDIR">
<Component Id="RegSetMsiSourceFolder">
<RegistryKey
Key="Software\AppName\Path"
Root="HKLM"
Action="createAndRemoveOnUninstall">
<RegistryValue Id="MsiPath"
Type="string"
Name="MsiPath"
Value="[SOURCEDIR]"/>
</RegistryKey>
</Component>
</ComponentGroup>

Then create a defered custom action that executes on InstallFinalize;

<CustomAction Id="CAName" Return="check" Execute="deferred" BinaryKey="CAName.CA.dll" DllEntry="CustomAction" Impersonate="no"/>

<Custom Action="CAName" Before="InstallFinalize">(NOT Installed) AND (NOT REMOVE) </Custom>

In custom action use either powershell or cmd command to move files.

By defering you get to keep admin elevation without needing to request it again.
 
Back
Top Bottom