我无法让自定义操作仅在我使用 Wix 卸载我的服务时运行。
<CustomAction Id='InstallService'
FileKey='Service.exe'
ExeCommand='install'
Execute='immediate'
Return='check'
Impersonate='yes'>NOT Installed</CustomAction>
<CustomAction Id='UninstallService'
FileKey='Service.exe'
ExeCommand='uninstall'
Execute='immediate'
Return='check'
Impersonate='yes'>Installed AND NOT REINSTALL</CustomAction>
<InstallExecuteSequence>
<Custom Action='UninstallService' After='StopServices'/>
<Custom Action='InstallService' Before='StartServices'/>
</InstallExecuteSequence>
这是组件...
<Component Id="ProductComponent">
<File Id="MyService.exe"
Name="MyService.exe"
Source="..\MyService\bin\Release\MyService.exe"
Vital="yes"
KeyPath="yes"
DiskId="1"/>
...
<ServiceControl Id='ServiceControl'
Name='MyService'
Start='install'
Stop='both'/>
</Component>
当我运行安装程序时,出现错误。查看事件日志,我发现这个......
产品:MyService -- 错误 1721。此 Windows 安装程序包有问题。无法运行完成此安装所需的程序。请联系您的支持人员或软件包供应商。操作:UninstallService,位置:C:\Program Files (x86)\MyService\MyService.exe,命令:卸载
我也试过这个...
<CustomAction Id='UninstallService'
FileKey='Service.exe'
ExeCommand='uninstall'
Execute='immediate'
Return='check'
Impersonate='yes'>Installed AND NOT UPGRADINGPRODUCTCODE</CustomAction>
注意:我使用自定义操作来安装/卸载服务,因为我使用了TopShelf.NET