wix 3.5 从用户指定目录卸载/升级

发布于 2024-12-27 18:19:07 字数 2138 浏览 0 评论 0原文

当我完成对用户定义路径的安装时,我希望基于 wix 的安装程序将我的应用程序卸载或升级到与默认目录不同的目录。

我已按照此处提到的步骤 http://wix.tramontana 进行操作。 co.hu/tutorial/getting-started/where-to-install 这是我现在在主 Product.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 application 的默认路径。通过日志,我看到 INSTALLDIR 在 Costfinalize 中设置为默认路径,但 Feature1.Dir 设置为注册表路径,这是实际的卸载路径。

有人可以建议在这种情况下该怎么做吗?我是否需要在 costfinalize 之后执行自定义操作,而不是实际设置注册表属性的 appsearch ?

问候, 拉吉

I would like a wix based installer to uninstall or upgrade my application to a different directory than the default directory when I have done the installation to a user defined path.

I have followed the step mentioned here http://wix.tramontana.co.hu/tutorial/getting-started/where-to-install and this is my wix code now in main Product.wxs

<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>

My features access the property using following code

<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>

I set the ARPINSTALLLOCATION property from mindcapers wiki about upgrade.

PROBLEM: During uninstall and upgrade it still picks up the default path for INSTALLDIR C:\Program Files\My application. Through the logs I see that INSTALLDIR is set in the Costfinalize to default path but the Feature1.Dir is set to the registry path which is the actuall uninstall path.

Can somebody suggest what to do in this case? Do I need to execute a custom action after costfinalize instead of the appsearch where the registry property is actually set?

Regards,
raj

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苦妄 2025-01-03 18:19:07

您必须在注册表中保存原始安装位置。然后,在升级时,您可以从注册表中将该值读取到 INSTALLDIR 属性中。

这与在命令行上设置 INSTALLDIR 具有相同的效果。

没有其他简单方法来检测先前版本的安装位置。 (我并不是说这是不可能确定的。)

You have to have saved the original install location in the registry. Then when upgrading, you read this value from the registry into INSTALLDIR property.

This will have the same effect as setting INSTALLDIR on the command line.

There's no other simple method to detect where the previous version was installed. (I don't say it's impossible to determine.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文