安装或主要升级的自定义操作

时间:2012-11-15 15:49:55

标签: wix wix3.5

我正在部署一些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.

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

  • 始终在安装后或升级后运行configure / install / start
  • 在卸载前或升级前始终运行停止/卸载

进一步测试。似乎ConfigureFor一直在运行,即使在“RemovePreviousProducts”阶段 - 为什么它不符合我的条件?

2 个答案:

答案 0 :(得分:1)

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

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

您可以找到可以使用here的Windows安装程序设置的更多属性。

答案 1 :(得分:1)

这个怎么样:

<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帖子可以帮助您: How to add a WiX custom action that happens only on uninstall (via MSI)?