Reputation: 4844
We are using Wix Toolset V3.11 to build our setup.
Because of the following declaration, our default installation Path is C:/Program Files(x86)/Acme/AppName
.
<Property Id="ApplicationFolderName" Value="$(var.Manufacturer)\$(var.AppFolderName)" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
Via the 'Advanced' button in the setup we change this path to C:/Program Files(x86)/Acme/FooBar
:
The following declaration saves the changed path in the registry:
<RegistryKey
Key="Software\$(var.Manufacturer)\$(var.AppName)"
Root="HKLM">
<RegistryValue Id="InstallationRegistry"
Type="string"
Name="InstallDir"
Value="[APPLICATIONFOLDER]" />
</RegistryKey>
Via Regedit.exe I can see the Path C:/Program Files(x86)/Acme/FooBar
in the Registry as expected. All okay.
Problem: But now, when I run a new setup which is an update, then all Files have been moved from the custom folder C:/Program Files(x86)/Acme/FooBar
to the default folder C:/Program Files(x86)/Acme/AppName
.
When I execute an update and click on the 'Advanced' button, then the default path C:/Program Files(x86)/Acme/AppName
is preallocated:
I use the following markup to query the Path out of the Registry:
<Property Id="APPLICATIONFOLDER">
<RegistrySearch Id='InstallationRegistrySearch' Type='raw' Root='HKLM' Key='Software\$(var.Manufacturer)\$(var.AppName)' Name='InstallDir' />
</Property>
Here is the relevant markup:
<Fragment>
<ComponentGroup Id="RootComponents" Directory="APPLICATIONFOLDER">
<Component Id="RootComponent" Guid="xxxxxxxxx" Win64='yes'>
<RegistryKey
Key="Software\$(var.Manufacturer)\$(var.AppName)"
Root="HKLM">
<RegistryValue Id="InstallationRegistry"
Type="string"
Name="InstallDir"
Value="[APPLICATIONFOLDER]" />
</RegistryKey>
</Component>
</ComponentGroup>
[...]
<Product ...>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="PROGRAMFILESPATH" Name="$(var.ProgramFilesPath)">
<Directory Id="ManufacturerFolder" Name="$(var.Manufacturer)">
<Directory Id="APPLICATIONFOLDER" Name="$(var.AppFolderName)" >
<!-- here are the application files (e.g. Appname.exe)-->
[...]
</Directory>
</Directory>
</Directory>
</Directory>
[...]
<Property Id="ApplicationFolderName" Value="$(var.Manufacturer)\$(var.AppFolderName)" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<Property Id="APPLICATIONFOLDER">
<RegistrySearch Id='InstallationRegistrySearch' Type='raw' Root='HKLM' Key='Software\$(var.Manufacturer)\$(var.AppName)' Name='InstallDir' />
</Property>
<Property Id="PREVIOUSVERSIONSINSTALLED" Secure="yes" />
<Property Id="ALLUSERS" Value="1"/>
[...]
<UI>
[...]
<UIRef Id="WixUI_Advanced"/>
</UI>
</Product>
What are we doing wrong?
Upvotes: 1
Views: 948
Reputation: 42216
Remember Properties: Property values are not auto-magically persisted by MSI, hence the need for patterns such as the "Remember Property Pattern".
Bitness: It looks like you are reading back from the registry, but could it be that you have a "bitness problem"? In other words you read from the x64-section of the registry and not the x86-section? (or vice versa).
HKEY_LOCAL_MACHINE\SOFTWARE\Manufacturer\Acme\Program
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Manufacturer\Acme\Program
Upvotes: 2