3

我有一些我正在部署的 TopShelf 服务的 Wix 安装程序。如何在重大升级期间配置完全卸载和重新安装?

目前我有一个一致的 UPGRADECODE、一个递增的 VERSION 和这个:

<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />

<InstallExecuteSequence>

  <!-- always run configure/install/start after installation OR after upgrading -->
  <Custom Action="ConfigureFor" Before="InstallFinalize">(NOT INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="InstallExporter" After="ConfigureFor">(NOT INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="StartExporter" After="InstallExporter">(NOT INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="InstallScheduler" After="ConfigureFor">(NOT INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="StartScheduler" After="InstallScheduler">(NOT INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>

  <!-- always run stop/uninstall before uninstallation OR before upgrading -->
  <Custom Action="StopExporter" Before="UninstallExporter">(INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="StopScheduler" Before="UninstallScheduler">(INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="UninstallExporter" After="InstallInitialize">(INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="UninstallScheduler" After="InstallInitialize">(INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>

</InstallExecuteSequence>

问题似乎是在重大升级的卸载部分期间调用了自定义操作 ConfigureFor...

Action start 17:36:08: INSTALL.
Action start 17:36:08: FindRelatedProducts.
Action ended 17:36:08: FindRelatedProducts. Return value 0.
Action start 17:36:08: AppSearch.
Action ended 17:36:08: AppSearch. Return value 1.
Action start 17:36:08: LaunchConditions.
Action ended 17:36:08: LaunchConditions. Return value 1.
Action start 17:36:08: ValidateProductID.
Action ended 17:36:08: ValidateProductID. Return value 1.
Action start 17:36:08: CostInitialize.
Action ended 17:36:08: CostInitialize. Return value 1.
Action start 17:36:08: FileCost.
Action ended 17:36:08: FileCost. Return value 1.
Action start 17:36:08: CostFinalize.
Action ended 17:36:08: CostFinalize. Return value 1.
Action start 17:36:08: MigrateFeatureStates.
Action ended 17:36:08: MigrateFeatureStates. Return value 0.
Action start 17:36:08: InstallValidate.
Action ended 17:36:22: InstallValidate. Return value 1.
Action start 17:36:22: RemoveExistingProducts.
Action ended 17:36:22: RemoveExistingProducts. Return value 0.
Action start 17:36:22: InstallInitialize.
Action ended 17:36:22: InstallInitialize. Return value 1.
Action start 17:36:22: SetUninstallExporter.
Action ended 17:36:22: SetUninstallExporter. Return value 1.
Action start 17:36:22: SetStopExporter.
Action ended 17:36:22: SetStopExporter. Return value 1.
Action start 17:36:22: SetUninstallScheduler.
Action ended 17:36:22: SetUninstallScheduler. Return value 1.
Action start 17:36:22: SetStopScheduler.
Action ended 17:36:22: SetStopScheduler. Return value 1.
Action start 17:36:22: ProcessComponents.
Action ended 17:36:22: ProcessComponents. Return value 1.
Action start 17:36:22: UnpublishFeatures.
Action ended 17:36:22: UnpublishFeatures. Return value 1.
Action start 17:36:22: RemoveRegistryValues.
Action ended 17:36:22: RemoveRegistryValues. Return value 1.
Action start 17:36:22: RemoveFiles.
Action ended 17:36:22: RemoveFiles. Return value 1.
Action start 17:36:22: InstallFiles.
Action ended 17:36:22: InstallFiles. Return value 1.
Action start 17:36:22: WriteRegistryValues.
Action ended 17:36:22: WriteRegistryValues. Return value 1.
Action start 17:36:22: RegisterUser.
Action ended 17:36:22: RegisterUser. Return value 0.
Action start 17:36:22: RegisterProduct.
Action ended 17:36:22: RegisterProduct. Return value 1.
Action start 17:36:22: PublishFeatures.
Action ended 17:36:22: PublishFeatures. Return value 1.
Action start 17:36:22: PublishProduct.
Action ended 17:36:22: PublishProduct. Return value 1.
Action start 17:36:22: SetConfigureFor.
Action ended 17:36:22: SetConfigureFor. Return value 1.
Action start 17:36:22: ConfigureFor.
Action ended 17:36:22: ConfigureFor. Return value 1.
Action start 17:36:22: SetInstallExporter.
Action ended 17:36:22: SetInstallExporter. Return value 1.
Action start 17:36:22: InstallExporter.
Action ended 17:36:22: InstallExporter. Return value 1.
Action start 17:36:22: SetStartExporter.
Action ended 17:36:22: SetStartExporter. Return value 1.
Action start 17:36:22: StartExporter.
Action ended 17:36:22: StartExporter. Return value 1.
Action start 17:36:22: SetInstallScheduler.
Action ended 17:36:22: SetInstallScheduler. Return value 1.
Action start 17:36:22: InstallScheduler.
Action ended 17:36:22: InstallScheduler. Return value 1.
Action start 17:36:22: SetStartScheduler.
Action ended 17:36:22: SetStartScheduler. Return value 1.
Action start 17:36:22: StartScheduler.
Action ended 17:36:22: StartScheduler. Return value 1.
Action start 17:36:22: InstallFinalize.
CAQuietExec:  The term 'c:\Program Files (x86)\Sunshine\configureFor.ps1' is not recognized a
CAQuietExec:  s the name of a cmdlet, function, script file, or operable program. Check the s
CAQuietExec:  pelling of the name, or if a path was included, verify that the path is correct
CAQuietExec:   and try again.
CAQuietExec:  At line:1 char:2
CAQuietExec:  + & <<<<  'c:\Program Files (x86)\Sunshine\configureFor.ps1' -environment   > '
CAQuietExec:  c:\Program Files (x86)\Sunshine\configureFor.log.txt'
CAQuietExec:      + CategoryInfo          : ObjectNotFound: (c:\Program File...onfigureFor.p 
CAQuietExec:     s1:String) , CommandNotFoundException
CAQuietExec:      + FullyQualifiedErrorId : CommandNotFoundException
CAQuietExec:   
CAQuietExec:  Error 0x80070001: Command line returned an error.
CAQuietExec:  Error 0x80070001: CAQuietExec Failed
CustomAction ConfigureFor returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 17:36:25: InstallFinalize. Return value 3.
Action ended 17:36:26: INSTALL. Return value 3.

我已经更新了上面的配置。这是我目前正在使用的。基本上,我们需要做的是:

  • 安装后或升级后始终运行配置/安装/启动
  • 在卸载或升级之前始终运行停止/卸载

经进一步测试。似乎 ConfigureFor 一直在运行,即使在“RemovePreviousProducts”阶段也是如此 - 为什么它不尊重我的条件?

4

2 回答 2

2

这个怎么样:

<InstallExecuteSequence>

  <!-- always run configure/install/start after installation OR after upgrading -->
  <Custom Action="ConfigureFor" Before="InstallFinalize">NOT (REMOVE ~= "ALL")</Custom>
  <Custom Action="InstallExporter" After="ConfigureFor">NOT (REMOVE ~= "ALL"))</Custom>
  <Custom Action="StartExporter" After="InstallExporter">NOT (REMOVE ~= "ALL")</Custom>
  <Custom Action="InstallScheduler" After="ConfigureFor">NOT (REMOVE ~= "ALL")</Custom>
  <Custom Action="StartScheduler" After="InstallScheduler">NOT (REMOVE ~= "ALL")</Custom>

  <!-- always run stop/uninstall before uninstallation OR before upgrading -->
  <Custom Action="StopExporter" Before="UninstallExporter">REMOVE ~= "ALL"</Custom>
  <Custom Action="StopScheduler" Before="UninstallScheduler">REMOVE ~= "ALL"</Custom>
  <Custom Action="UninstallExporter" After="InstallInitialize">REMOVE ~= "ALL"</Custom>
  <Custom Action="UninstallScheduler" After="InstallInitialize">REMOVE ~= "ALL"</Custom>

</InstallExecuteSequence>

此外,这篇 SO 帖子可能会对您有所帮助: 如何添加仅在卸载时发生的 WiX 自定义操作(通过 MSI)?

于 2012-11-20T16:05:58.590 回答
1

尝试使用添加AND OR UPGRADINGPRODUCTCODE使您的代码看起来像:

<Custom Action="ConfigureFor" Before="InstallFinalize">(NOT INSTALLED OR NOT UPGRADINGPRODUCTCODE)</Custom>

您可以在此处找到更多由 Windows 安装程序设置的属性。

于 2012-11-16T20:18:30.273 回答