windows - WiX 在重大升级后删除 Windows 服务

标签 windows wix wix3.8

我在大约十分之一的系统上使用 WiX 进行重大升级时发现间歇性问题。 Windows 服务在卸载旧版本产品时被删除,然后在安装新版本产品时安装并启动。但是 1 或 2 秒后,新版本的 Windows 服务被卸载。我认为这可能违反了组件规则或文件版本控制规则,例如 this question ,但我没有在 WiX 脚本中看到问题。我没有更改组件 GUID 或引用其他组件中的资源,Windows 服务 exe 将从版本 1.4.3 升级到 1.4.7。

升级失败后,我可以卸载新版产品,安装老版产品,然后大升级到新版产品,没有任何问题。在第一次初始升级失败后,所有其他升级都可以工作。任何帮助将不胜感激。

代码是:

<RemoveExistingProducts After="InstallExecute" />

<Component Id="ProgFiles" Guid="C692BAF6-17DB-4E8B-8225-9F0614080B16" Shared="no" Permanent="no">

        <ServiceInstall Id="InstallWindowsService"
                        Name="$(var.WindowsServiceName)"
                        DisplayName="[WINDOWS_SERVICE_DISPLAY_NAME]"
                        Type="ownProcess"
                        Start="auto"
                        ErrorControl="critical"
                        Description="$(var.AppDescription)">

            <ServiceConfig Id="WindowsServiceConfig"
                           DelayedAutoStart="yes"
                           OnInstall="yes"
                           OnReinstall="yes"/>              
        </ServiceInstall>
       <File Id='_04' DiskId='1' Name='Service.exe'                  Source='..\bin\$(var.BinariesToUse)\Service.exe' KeyPath='yes'/>
    </Component>
         <Component Id="ReleaseInstallRegEntries" Guid="5AB1B28B-C884-4230-9275-4095DDD06085" Shared="no" Permanent="no">
              <ServiceControl Id="WindowsServiceControl_USER"
                              Name="$(var.WindowsServiceName)"
                              Stop="both"
                              Start="install"
                              Remove="uninstall"
                              Wait="yes" />
            </Component>
    <Upgrade Id="$(var.UpgradeCode)">

    <UpgradeVersion Minimum="$(var.ProductVersion)"
                    IncludeMinimum="no"
                    OnlyDetect="yes"
                    Language="1033"
                    Property="NEWERPRODUCTFOUND" />

    <UpgradeVersion Minimum="0.0.0"
                    IncludeMinimum="yes"
                    Maximum="$(var.ProductVersion)"
                    IncludeMaximum="no"
                    Language="1033"
                    Property="UPGRADEFOUND" />

</Upgrade>

here 下载的整个 msi 安装日志

msi 安装日志:

MSI (s) (60:74) [12:09:04:691]: Doing action: RemoveExistingProducts
MSI (s) (60:74) [12:09:04:691]: Note: 1: 2205 2:  3: ActionText 
Action ended 12:09:04: PublishProduct. Return value 1.
MSI (s) (60:74) [12:09:04:691]: Skipping RemoveExistingProducts action: current configuration is maintenance mode or an uninstall
Action start 12:09:04: RemoveExistingProducts.
MSI (s) (60:74) [12:09:04:691]: Doing action: CleanUpgradeFolder
MSI (s) (60:74) [12:09:04:691]: Note: 1: 2205 2:  3: ActionText 
Action ended 12:09:04: RemoveExistingProducts. Return value 0.
Action start 12:09:04: CleanUpgradeFolder.
MSI (s) (60:74) [12:09:04:691]: Skipping action: WixFailWhenDeferred (condition is false)
MSI (s) (60:74) [12:09:04:691]: Doing action: InstallFinalize
MSI (s) (60:74) [12:09:04:691]: Note: 1: 2205 2:  3: ActionText 
Action ended 12:09:04: CleanUpgradeFolder. Return value 1.
MSI (s) (60:74) [12:09:04:691]: Running Script: C:\Windows\Installer\MSI4518.tmp
MSI (s) (60:74) [12:09:04:691]: PROPERTY CHANGE: Adding UpdateStarted property. Its value is '1'.
MSI (s) (60:74) [12:09:04:769]: Note: 1: 2265 2:  3: -2147287035 
MSI (s) (60:74) [12:09:04:769]: Machine policy value 'DisableRollback' is 0
MSI (s) (60:74) [12:09:04:769]: Executing op: Header(Signature=1397708873,Version=500,Timestamp=1225810211,LangId=1033,Platform=0,ScriptType=1,ScriptMajorVersion=21,ScriptMinorVersion=4,ScriptAttributes=1)
Action start 12:09:04: InstallFinalize.
MSI (s) (60:74) [12:09:04:769]: Executing op: ProductInfo(ProductKey={2BFA1207-9A98-4D55-9182-5C433ED6A55A},ProductName=Dell Customer Connect,PackageName=OTBSurvey.1.4.3.0.msi,Language=1033,Version=17039363,Assignment=1,ObsoleteArg=0,ProductIcon=dnd.ico,,PackageCode={11C5914C-B010-41D1-B920-D4C97AC61404},,,InstanceType=0,LUASetting=0,RemoteURTInstalls=0,ProductDeploymentFlags=3)
MSI (s) (60:74) [12:09:04:769]: Executing op: DialogInfo(Type=0,Argument=1033)
MSI (s) (60:74) [12:09:04:769]: Executing op: DialogInfo(Type=1,Argument=Dell Customer Connect)
MSI (s) (60:74) [12:09:04:769]: Executing op: RollbackInfo(,RollbackAction=Rollback,RollbackDescription=Rolling back action:,RollbackTemplate=[1],CleanupAction=RollbackCleanup,CleanupDescription=Removing backup files,CleanupTemplate=File: [1])
MSI (s) (60:74) [12:09:04:769]: Executing op: SetBaseline(Baseline=0,)
MSI (s) (60:74) [12:09:04:769]: Executing op: SetBaseline(Baseline=1,)
MSI (s) (60:74) [12:09:04:769]: Executing op: ActionStart(Name=InstallInitialize,,)
MSI (s) (60:74) [12:09:04:785]: Executing op: ProductUnregister(UpgradeCode={29D88272-5B32-4441-B6F3-568230D61331})
MSI (s) (60:74) [12:09:04:785]: Note: 1: 1402 2: UNKNOWN\Products\7021AFB289A955D41928C534E36D5AA5\Transforms 3: 2 
MSI (s) (60:74) [12:09:04:785]: Note: 1: 1402 2: UNKNOWN\Products\7021AFB289A955D41928C534E36D5AA5\Transforms 3: 2 
MSI (s) (60:74) [12:09:04:785]: Scheduling file 'C:\Windows\Installer\74bb8.msi' for deletion during post-install cleanup (not post-reboot).
MSI (s) (60:74) [12:09:04:800]: Note: 1: 1402 2: UNKNOWN\Products\7021AFB289A955D41928C534E36D5AA5\Usage 3: 2 
MSI (s) (60:74) [12:09:04:800]: Executing op: ProductCPDisplayInfoUnregister()
MSI (s) (60:74) [12:09:04:800]: Executing op: ProductUnpublish(PackageKey={11C5914C-B010-41D1-B920-D4C97AC61404})
MSI (s) (60:74) [12:09:04:800]: Using cached product context: machine assigned for product: 7021AFB289A955D41928C534E36D5AA5
MSI (s) (60:74) [12:09:04:816]: Executing op: UpgradeCodeUnpublish(UpgradeCode={29D88272-5B32-4441-B6F3-568230D61331})
MSI (s) (60:74) [12:09:04:816]: Executing op: IconRemove(Icon=dnd.ico,)
MSI (s) (60:74) [12:09:04:816]: Scheduling file 'C:\Windows\Installer\{2BFA1207-9A98-4D55-9182-5C433ED6A55A}\dnd.ico' for deletion during post-install cleanup (not post-reboot).
MSI (s) (60:74) [12:09:04:816]: Executing op: ProductUnpublishClient(,,)
MSI (s) (60:74) [12:09:04:816]: Note: 1: 1402 2: UNKNOWN\Installer\Products\7021AFB289A955D41928C534E36D5AA5 3: 2 
MSI (s) (60:74) [12:09:04:816]: Executing op: SourceListUnpublish(,)
MSI (s) (60:74) [12:09:04:816]: Note: 1: 1402 2: UNKNOWN\Installer\Products\7021AFB289A955D41928C534E36D5AA5\SourceList 3: 2 
MSI (s) (60:74) [12:09:04:816]: Executing op: ActionStart(Name=ProcessComponents,Description=Updating component registration,)
MSI (s) (60:74) [12:09:04:816]: Executing op: ProgressTotal(Total=12,Type=1,ByteEquivalent=24000)
MSI (s) (60:74) [12:09:04:816]: Executing op: UnregisterSharedComponentProvider(Component={F48BF778-F931-42C4-9D18-BE9A27E1D9F9},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:816]: Executing op: ComponentUnregister(ComponentId={F48BF778-F931-42C4-9D18-BE9A27E1D9F9},,BinaryType=0,PreviouslyPinned=1)
MSI (s) (60:74) [12:09:04:816]: Executing op: UnregisterSharedComponentProvider(Component={9A35F430-54AA-4FD6-9936-DD72910CF898},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:816]: Executing op: ComponentUnregister(ComponentId={9A35F430-54AA-4FD6-9936-DD72910CF898},,BinaryType=0,PreviouslyPinned=1)
MSI (s) (60:74) [12:09:04:816]: Executing op: UnregisterSharedComponentProvider(Component={DAA28A1B-1403-49C5-966E-E8C1989061D0},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:816]: Executing op: ComponentUnregister(ComponentId={DAA28A1B-1403-49C5-966E-E8C1989061D0},,BinaryType=0,PreviouslyPinned=1)
MSI (s) (60:74) [12:09:04:816]: Executing op: UnregisterSharedComponentProvider(Component={4F8B0F06-392A-4963-8A99-B32F436F802D},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:816]: Executing op: ComponentUnregister(ComponentId={4F8B0F06-392A-4963-8A99-B32F436F802D},,BinaryType=0,PreviouslyPinned=1)
MSI (s) (60:74) [12:09:04:816]: Executing op: UnregisterSharedComponentProvider(Component={1FF47611-4ABF-4A40-8278-133E73DF0461},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:816]: Executing op: ComponentUnregister(ComponentId={1FF47611-4ABF-4A40-8278-133E73DF0461},,BinaryType=0,PreviouslyPinned=1)
MSI (s) (60:74) [12:09:04:816]: Executing op: UnregisterSharedComponentProvider(Component={A2612202-F609-4C42-8FBC-2BE733A3D1FB},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:816]: Executing op: ComponentUnregister(ComponentId={A2612202-F609-4C42-8FBC-2BE733A3D1FB},,BinaryType=0,PreviouslyPinned=1)
MSI (s) (60:74) [12:09:04:816]: Executing op: UnregisterSharedComponentProvider(Component={9817EEDA-E4CC-4B5A-B97D-F9CF0C7DF493},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:816]: Executing op: ComponentUnregister(ComponentId={9817EEDA-E4CC-4B5A-B97D-F9CF0C7DF493},,BinaryType=0,PreviouslyPinned=1)
MSI (s) (60:74) [12:09:04:816]: Executing op: UnregisterSharedComponentProvider(Component={23FB7BF8-C385-4FE2-8A3F-AC4D7BE23CAF},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:816]: Executing op: ComponentUnregister(ComponentId={23FB7BF8-C385-4FE2-8A3F-AC4D7BE23CAF},,BinaryType=0,PreviouslyPinned=1)
MSI (s) (60:74) [12:09:04:816]: Executing op: UnregisterSharedComponentProvider(Component={350DEE79-78D9-46B6-8442-90A9299C8DDD},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:816]: Executing op: ComponentUnregister(ComponentId={350DEE79-78D9-46B6-8442-90A9299C8DDD},,BinaryType=0,)
MSI (s) (60:74) [12:09:04:832]: Executing op: UnregisterSharedComponentProvider(Component={8B227A34-6400-433B-84BD-F4BA9CC26E75},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:832]: Executing op: ComponentUnregister(ComponentId={8B227A34-6400-433B-84BD-F4BA9CC26E75},,BinaryType=0,PreviouslyPinned=1)
MSI (s) (60:74) [12:09:04:832]: Executing op: UnregisterSharedComponentProvider(Component={0DE95021-65AC-47DD-9158-A931C0363522},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:832]: Executing op: ComponentUnregister(ComponentId={0DE95021-65AC-47DD-9158-A931C0363522},,BinaryType=0,PreviouslyPinned=1)
MSI (s) (60:74) [12:09:04:832]: Executing op: UnregisterSharedComponentProvider(Component={CB46CF46-8580-4739-84BE-A7F8005B88AA},ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A})
MSI (s) (60:74) [12:09:04:832]: Executing op: ComponentUnregister(ComponentId={CB46CF46-8580-4739-84BE-A7F8005B88AA},,BinaryType=0,PreviouslyPinned=1)
MSI (s) (60:74) [12:09:04:832]: Executing op: ActionStart(Name=UnpublishFeatures,Description=Unpublishing Product Features,Template=Feature: [1])
MSI (s) (60:74) [12:09:04:832]: Executing op: FeatureUnpublish(Feature=MainFeature,,Absent=2,Component=oOhZwZc(O93_IgYZf`AysfrWYMS(aAH`zvLW+y1YKOr=oNHBe?(lECg)&h{kng%XA4jrY?**1D3.j'^2of{=-h$Or?u3qy72QN3GP8%4]bMHS@-6DAsx2KxyL5%tX%L]6@$$_pk6?{VWgq~W.N@IbAAYxz@snACa!~H'5xXlf=$O@R_YxY5p*P!fTand[9pcL*el).hM7d&P'`i=+?B@dz3w@T~-Pn@DjY@kt=bq}vxbrim_)
MSI (s) (60:74) [12:09:04:832]: Note: 1: 1402 2: UNKNOWN\Installer\Features\7021AFB289A955D41928C534E36D5AA5 3: 2 
MSI (s) (60:74) [12:09:04:832]: Executing op: ActionStart(Name=StopServices,Description=Stopping services,Template=Service: [1])
MSI (s) (60:74) [12:09:04:832]: Executing op: ProgressTotal(Total=1,Type=1,ByteEquivalent=1300000)
MSI (s) (60:74) [12:09:04:832]: Executing op: ServiceControl(,Name=Dell Customer Connect,Action=2,Wait=1,)
MSI (s) (60:74) [12:09:19:681]: Executing op: ActionStart(Name=DeleteServices,Description=Deleting services,Template=Service: [1])
MSI (s) (60:74) [12:09:19:681]: Executing op: ProgressTotal(Total=1,Type=1,ByteEquivalent=1300000)
MSI (s) (60:74) [12:09:19:681]: Executing op: ServiceControl(,Name=Dell Customer Connect,Action=8,Wait=1,)
MSI (s) (60:74) [12:09:19:681]: Executing op: ActionStart(Name=InstallFiles,Description=Copying new files,Template=File: [1],  Directory: [9],  Size: [6])
MSI (s) (60:74) [12:09:19:681]: Executing op: RemoveBaseline(ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A},ProductVersion=1.4.3)
MSI (s) (60:74) [12:09:19:681]: Verifying accessibility of file: _01
MSI (s) (60:74) [12:09:19:696]: Verifying accessibility of file: _04
MSI (s) (60:74) [12:09:19:696]: Verifying accessibility of file: _05
MSI (s) (60:74) [12:09:19:696]: Verifying accessibility of file: _06
MSI (s) (60:74) [12:09:19:712]: Verifying accessibility of file: _16
MSI (s) (60:74) [12:09:19:712]: Verifying accessibility of file: _17
MSI (s) (60:74) [12:09:19:728]: Verifying accessibility of file: _19
MSI (s) (60:74) [12:09:19:728]: Verifying accessibility of file: _20
MSI (s) (60:74) [12:09:19:728]: Verifying accessibility of file: _21
MSI (s) (60:74) [12:09:19:743]: Verifying accessibility of file: _22
MSI (s) (60:74) [12:09:19:743]: Verifying accessibility of file: _40
MSI (s) (60:74) [12:09:19:771]: Verifying accessibility of file: _41
MSI (s) (60:74) [12:09:19:786]: Verifying accessibility of file: _42
MSI (s) (60:74) [12:09:19:786]: Verifying accessibility of file: _43
MSI (s) (60:74) [12:09:19:802]: Verifying accessibility of file: _44
MSI (s) (60:74) [12:09:19:802]: Verifying accessibility of file: _77
MSI (s) (60:74) [12:09:19:802]: Verifying accessibility of file: _78
MSI (s) (60:74) [12:09:19:818]: Verifying accessibility of file: _79
MSI (s) (60:74) [12:09:19:818]: Verifying accessibility of file: _80
MSI (s) (60:74) [12:09:19:818]: Verifying accessibility of file: _81
MSI (s) (60:74) [12:09:19:818]: Verifying accessibility of file: _82
MSI (s) (60:74) [12:09:19:833]: Note: 1: 2318 2: C:\Windows\Installer\$PatchCache$\Managed\7021AFB289A955D41928C534E36D5AA5\CacheSize.txt 
MSI (s) (60:74) [12:09:19:833]: Executing op: RemoveBaseline(ProductCode={2BFA1207-9A98-4D55-9182-5C433ED6A55A},)
MSI (s) (60:74) [12:09:19:833]: Verifying accessibility of file: CacheSize.txt
MSI (s) (60:74) [12:09:19:833]: Executing op: ActionStart(Name=PublishProduct,Description=Publishing product information,)
MSI (s) (60:74) [12:09:19:833]: Executing op: CleanupConfigData()
MSI (s) (60:74) [12:09:19:833]: Executing op: RegisterPatchOrder(Continue=0,SequenceType=0,Remove=1)
MSI (s) (60:74) [12:09:19:833]: Note: 1: 1402 2: UNKNOWN\Installer\Products\7021AFB289A955D41928C534E36D5AA5\Patches 3: 2 
MSI (s) (60:74) [12:09:19:833]: Executing op: RegisterPatchOrder(Continue=0,SequenceType=1,Remove=1)
MSI (s) (60:74) [12:09:19:833]: Executing op: CleanupConfigData(RemovingProduct=1)
MSI (s) (60:74) [12:09:19:833]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\7021AFB289A955D41928C534E36D5AA5\Patches 3: 2 
MSI (s) (60:74) [12:09:19:833]: Executing op: ActionStart(Name=CleanUpgradeFolder,,)
MSI (s) (60:74) [12:09:19:833]: Executing op: CustomActionSchedule(Action=CleanUpgradeFolder,ActionType=3110,Source='MsgBox Session.Property("CleanUpgradeFolder")

      'delete the settings file:

      Set filesys = CreateObject("Scripting.FileSystemObject")
      sSettingsFilePath = "C:\ProgramData\Dell\OTBS\OTBSService.State.settings"

      If filesys.FileExists(sSettingsFilePath) Then
        filesys.DeleteFile sSettingsFilePath
      End If,,)
MSI (s) (60:74) [12:09:19:833]: Creating MSIHANDLE (7) of type 790536 for thread 884
MSI (s) (60:78) [12:09:19:833]: Creating MSIHANDLE (8) of type 0 for thread 1912
MSI (s) (60:78) [12:09:19:861]: Closing MSIHANDLE (8) of type 0 for thread 1912
MSI (s) (60:78) [12:09:19:861]: Closing MSIHANDLE (7) of type 790536 for thread 884
MSI (s) (60:74) [12:09:19:861]: Executing op: End(Checksum=0,ProgressTotalHDWord=0,ProgressTotalLDWord=2888000)
MSI (s) (60:74) [12:09:19:877]: PROPERTY CHANGE: Deleting UpdateStarted property. Its current value is '1'.

windows服务日志:

2016-08-16 17:08:59,522 [1776] INFO  Service shutting down.    [ShutDownService]
2016-08-16 17:08:59,616 [1776] DEBUG    Service Stopped    [PreStopOperations]
2016-08-16 17:09:03,488 [3868] INFO  Service Started; Client Version: 1.4.7.0; OS: WIN8; Thread UI: en-US; Installed UI: en-US    [OnStart]
2016-08-16 17:09:04,832 [3868] INFO  OTBSurveyService: Stop event received    [OnStop]
2016-08-16 17:09:04,847 [3868] INFO  Service shutting down.    [ShutDownService]
2016-08-16 17:09:18,931 [3868] DEBUG    Service Stopped    [PreStopOperations]

最佳答案

根据日志和 RemoveExistingProducts 文档。当您的升级发生在 afterInstallExecute 时,实际的事件顺序是首先安装新版本,然后卸载旧产品。

在 12:08:59 停止旧服务(从升级安装),然后删除旧服务。 然后安装新服务,并在 12:09:03.222 启动,服务配置操作也在那里进行。 在 12:09:04.535 RemoveExistingProducts 运行,卸载旧产品。那个uninstall在12:09:04:832有一个ServiceControl来停止服务(你刚刚安装的那个),因为你的ServiceControl有stop=both,也就是说它会在卸载的时候停止它,这个是旧版本的uninstall产品。

由于这是静态定义的行为,也许对可变行为最可能的解释是计时赛跑。例如,您新安装的服务可能还没有准备好接受大多数安装中的停止请求,因此它不会在旧产品卸载时停止。但是有时它确实会响应并关闭。

然而,撇开理论不谈,底线仍然是您拥有带有 ServiceControl stop=both 的代码,并且卸载带有 stop 的旧产品是最后发生的事情(请注意,您仅在安装时开始,不是卸载!)。您可能需要更改升级顺序,因为 stop=both 在较旧的已安装产品中,例如,如果不使用补丁更改它就无法修复。您的升级 afterInstallInitialize 应该没问题,因为安装实际上是在卸载旧产品之后进行的。

关于windows - WiX 在重大升级后删除 Windows 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38920798/

相关文章:

java - 如何在 Java 中查找 "My Documents"文件夹

javascript - 如何从使用 wix 创建的 .msi 文件安装 Web 应用程序?

WIX 目录搜索总是失败

wix - Wix 中的 CustomAction 未执行

windows - 命令行网页浏览

javascript - 有没有什么方法可以以编程方式启动应用程序,以便它在快照 View 中启动?

java - 检测 Windows 还是 Linux?

wix 工具集构建工具未安装

Wix 工具集 : complete cleanup after "disallowing uninstallation of component since another client exists"

c# - ICE64 : The directory ApplicationProgramsFolder is in the user profile but is not listed in the RemoveFile table