Skip to content

Commit b479932

Browse files
authored
Merge pull request #51 from dorssel/install_location
Allow overriding install location
2 parents 715eaad + d8d01c9 commit b479932

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Installer/Product.wxs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,38 @@ SPDX-License-Identifier: GPL-2.0-only
3939

4040
<Property Id="MSIDEPLOYMENTCOMPLIANT" Value="1" />
4141

42+
<!--
43+
MSI specifies that TARGETDIR overrides the default installation location, and winget relies on that.
44+
WiX, however, uses APPLICATIONFOLDER.
45+
So, if TARGETDIR is set and APPLICATIONFOLDER is not, then copy TARGETDIR to APPLICATIONFOLDER.
46+
See:
47+
https://docs.microsoft.com/en-us/windows/win32/msi/targetdir
48+
https://docs.microsoft.com/en-us/windows/win32/msi/changing-the-target-location-for-a-directory
49+
-->
50+
<SetProperty Action="UseTARGETDIR" Id="APPLICATIONFOLDER" Value="[TARGETDIR]" Before="PreserveCurrentInstallationLocation" Sequence="first">TARGETDIR AND NOT APPLICATIONFOLDER</SetProperty>
51+
52+
<!--
53+
Get the current installation location (if any).
54+
-->
55+
<Property Id="CURRENTINSTALLATIONLOCATION">
56+
<RegistrySearch Id="APPLICATIONFOLDER"
57+
Root="HKLM"
58+
Key="SOFTWARE\usbipd-win"
59+
Name="APPLICATIONFOLDER"
60+
Type="directory"
61+
/>
62+
</Property>
63+
64+
<!--
65+
If the product is currently installed and the APPLICATIONFOLDER has not been set yet, then preserve the current installation directory.
66+
This allows users to:
67+
a) specify a non-default installation location on first install, which is then preserved when updating using defaults.
68+
b) specify APPLICATIONFOLDER (or TARGETDIR) when updating, which will change the installation directory.
69+
-->
70+
<SetProperty Action="PreserveCurrentInstallationLocation" Id="APPLICATIONFOLDER" Value="[CURRENTINSTALLATIONLOCATION]" Before="CostInitialize" Sequence="first">CURRENTINSTALLATIONLOCATION AND NOT APPLICATIONFOLDER</SetProperty>
71+
72+
<SetProperty Id="ARPINSTALLLOCATION" Value="[APPLICATIONFOLDER]" After="CostFinalize" />
73+
4274
<Feature
4375
Id="Server"
4476
Level="1"

0 commit comments

Comments
 (0)