我希望基于wix的安装程序在安装到用户定义的路径时将我的应用程序卸载或升级到默认目录以外的其他目录。
我已经按照此处提到的步骤http://wix.tramontana.co.hu/tutorial/getting-started/where-to-install进行了操作,这是我现在主要的产品.wxs中的wix代码
<Upgrade Id="{UPGRRADE-GUID}">
<UpgradeVersion Minimum="$(var.ProductVersion)" Property="NEWERPRODUCTFOUND" OnlyDetect="yes" IncludeMinimum="yes" />
<UpgradeVersion Minimum="0.0.0" Maximum="$(var.ProductVersion)" Property="PREVIOUSVERSIONSINSTALLED" IncludeMinimum="yes" />
</Upgrade>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.programDir)">
<Directory Id="INSTALLDIR" Name="$(var.InstallDir)"/>
</Directory>
</Directory>
<!-- Find previous installation -->
<Property Id="INSTALLDIR">
<RegistrySearch Id="FindInstallLocation"
Root="HKLM"
Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[PREVIOUSVERSIONSINSTALLED]"
Name="InstallLocation"
Type="raw" />
</Property>
<InstallExecuteSequence>
<FindRelatedProducts Before="LaunchConditions"/>
<AppSearch After="FindRelatedProducts"/>
<RemoveExistingProducts Before="InstallInitialize" />
</InstallExecuteSequence>
我的功能使用以下代码访问该媒体资源
<DirectoryRef Id="INSTALLDIR">
<Directory Id="Feature1.Dir" Name="$(var.AddInName)">
<Component Id = "Addin" Guid="COMP-GUID">
</Directory>
</DirectoryRef>
<Feature Id="FeatureOne" Level="1" ConfigurableDirectory="INSTALLDIR" Title="$(var.ServiceDisplayName)" Description="$(var.ServiceDescription)" Absent="allow">
<ComponentRef Id="AddIn"/>
</Feature>
我从mindcapers wiki中设置了关于升级的ARPINSTALLLOCATION属性。
问题:在卸载和升级期间,它仍然会选择INSTALLDIR C:\ Program Files \ My应用程序的默认路径。通过日志,我看到INSTALLDIR在Costfinalize中设置为默认路径,但Feature1.Dir设置为注册表路径,即实际卸载路径。
在这种情况下,有人可以建议做些什么吗?我是否需要在costfinalize之后执行自定义操作,而不是实际设置注册表属性的appsearch?
此致 拉吉
答案 0 :(得分:2)
您必须在注册表中保存原始安装位置。然后在升级时,将此值从注册表中读取到INSTALLDIR
属性。
这与在命令行上设置INSTALLDIR
具有相同的效果。
没有其他简单方法可以检测以前版本的安装位置。 (我不是说不可能确定。)