Reputation: 333
I have a Windows app which has 2 versions, kind of, but a different name for each version. I use the same .wxs to build because I have no reasons to create a second wix project. I do not want to argue wether it is a good idea in here.
The thing is: each version must be installed in
path \ mainDir \ versionDir
Where path \ mainDir is the same for each version. My problem is that mainDir is being entirely overwritten on install by each version. Let's say I install version1, I'll have
path \ mainDir \ version1Dir
And then if I install version2, instead of having
path \ mainDir \ version1Dir
path \ mainDir \ version2Dir
I'll have
path \ mainDir \ version2Dir
I've been trying to get this around using Wix - how to prevent overwrite entire directory?, but it only applies to files since Conditions cannot be assigned to directories (or maybe I have haven't found how to do so, I don't know).
My goal is to have each versions able to install in its own directory, creating mainDir if it doesn't exist, but only removing it if it's empty.
Here's the code, any leads would be very much appreciated.
<!-- This is in Product, I'm just pasting it here -->
<Property Id="ALREADYINSTALLED">
<RegistrySearch Id="InstallPath" Key="Software\$(var.MainDir)" Name="MainFolder" Root="HKCU" Type="directory" />
</Property>
<Property Id="SECONDALREADYINSTALLED">
<RegistrySearch Id="SecondInstallPath" Key="Software\$(var.MainDir)\$(var.SecondDir)" Name="SecondFolder" Root="HKCU" Type="directory" />
</Property>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="WINDOWSVOLUME">
<Directory Id="INSTALLFOLDER" Name=".">
<Directory Id="MAINFOLDER" Name="$(var.MainDir)">
<!-- Allows the removal of this directory on uninstall -->
<Component Id="mainFolderRemoval">
<RegistryValue Root="HKCU" Key="Software\$(var.MainDir)" Name="MainFolder" Type="string" KeyPath="yes" />
<RemoveFolder Id="removal" On="uninstall" Property="ALREADYINSTALLED"/>
</Component>
<Directory Id="SECONDFOLDER" Name="$(var.SecondDir)">
<Component Id="secondFolderRemoval">
<RegistryValue Root="HKCU" Key="Software\$(var.MainDir)\$(var.SecondDir)" Name="SecondFolder" Type="string" KeyPath="yes" />
<util:RemoveFolderEx On="uninstall" Property="SECONDALREADYINSTALLED"/>
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
<SetDirectory Id="WINDOWSVOLUME" Value="[WindowsVolume]" />
<!-- Overwrites the main folder if already installed -->
<SetDirectory Id="MAINFOLDER" Value="[ALREADYINSTALLED]"> <![CDATA[ALREADYINSTALLED]]> </SetDirectory>
</Fragment>
Upvotes: 1
Views: 171
Reputation: 333
So I ended up finding why it wouldn't work. You have to make sure that your product upgrade code is different for each version, which was quite obvious actually.
One could argue that I should delete this post, but I believe it could happen to anyone and this is too much of a stupid issue to let people loose time with this. I'll leave this question as an example, hopefully it might be useful to somebody in the future.
Upvotes: 2