所以我尝试安装使用TopShelf构建的应用程序,应用程序本身运行良好且没有问题。我遇到的问题是当我尝试安装服务时。使用myapp.exe install <options>
指令安装TopShelf服务(从管理员命令行)。我已将指令包装在自定义操作中(参见下文)。这样运行,我可以在安装时看到一个黑框弹出窗口。但是,该服务无法安装。当我从管理员命令行运行msi安装时,该服务正确安装。我在WiX文件中包含了所有与管理员相关的参数(也见下文)。我完全没有想法,需要帮助,任何人都可以在WiX文件中看到任何内容,或者有人知道是什么阻止了服务的安装吗?
我尝试过:
Topshelf - Custom Action in Wix Not Executing
Add Coffee and Shake Well - TopShelf
我还尝试在单独的WiX自定义Action项目中将对topshelf应用程序的调用包装起来执行,但出于同样的原因,这也失败了。
<Product Id="*" Name="PackageName"
Language="1033"
Version="1.0.0.0"
Manufacturer="Manufacturer"
UpgradeCode="e7780903-3cf9-4ecc-b65a-45bc18b500df">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
InstallPrivileges="elevated"
Platform="x64" />
<Property Id="MSIUSEREALADMINDETECTION" Value="1" />
<MajorUpgrade AllowSameVersionUpgrades="yes"
DowngradeErrorMessage="A newer version of [ProductName] is already installed."
Schedule="afterInstallInitialize" />
<MediaTemplate EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="FeatureName" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<CustomAction Id="InstallService"
FileKey="MyApp.exe"
ExeCommand="install"
Impersonate="yes"
Execute="immediate" />
<CustomAction Id="StopService"
FileKey="MyApp.exe"
ExeCommand="stop"
Execute="immediate" />
<CustomAction Id="UninstallService"
FileKey="MyApp.exe"
ExeCommand="uninstall"
Execute="immediate" />
<InstallExecuteSequence>
<Custom Action="InstallService" After="InstallFinalize" >
NOT Installed AND NOT REMOVE
</Custom>
<Custom Action="StopService" After="InstallInitialize" >
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
<Custom Action="UninstallService" After="StopService">
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
</InstallExecuteSequence>
</Product>
答案 0 :(得分:1)
您的自定义操作存在一些问题。一个是InstallService CA是立即的,这意味着1)它是在文件安装之前和2)它不会以高程运行。它需要在InstallFinalize之前延迟。
如果这只是普通的Windows服务,那么您应该使用ServiceInstall节点来安装它(并将其卸载)以及ServiceControl来停止,启动和删除它。
答案 1 :(得分:0)
我用下面的代码解决了这个问题
<CustomAction Id="InstallService" FileKey="MyApp.exe" ExeCommand="install start" Impersonate="no" Execute="deferred" />
<CustomAction Id="UninstallService" FileKey="MyApp.exe" ExeCommand="stop uninstall" Impersonate="no" Execute="deferred" />
<InstallExecuteSequence>
<Custom Action="InstallService" Before="InstallFinalize">
NOT Installed AND NOT REMOVE
</Custom>
<Custom Action="UninstallService" Before="RemoveFiles">
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
</InstallExecuteSequence>