我正在努力让 MajorUpgrade、ServiceControl、.config 文件很好地协同工作。 在我的另一个问题之后,我现在又遇到了相反的问题。
之前,文件没有被覆盖,因为 AssemblyFileVersions 是静态的,所以我修复了它。 1)现在,即使Schedule="afterInstallExecute"
我的KeyPath='yes'
.config文件仍然被覆盖,即使现有文件修改日期与文件创建日期不同并且它被设置为 KeyPath。我目前不得不覆盖.config文件并在安装后重新启动服务。
2)即使我解决了这个问题,我仍然有避免重新启动的问题。如果我这么说Schedule="afterInstallInitialize"
,那么我相信 .config 文件肯定会与服务一起过早地被删除。如果我说Schedule="afterInstallExecute"
服务没有停止,安装后需要重新启动。(没错,对吧?)在安装之前手动停止服务让我避免重新启动。添加net stop
自定义操作可以代替ServiceControl
我猜的,但是让所有条件都正确似乎很复杂。
3)作为奖励,我不想在升级期间完全删除该服务。我可以停止服务,替换二进制文件,然后重新启动服务吗?这将避免为升级重新输入服务帐户凭据。但当然,它仍然需要在第一次安装时安装并在删除功能时卸载。
这是它的主要内容(稍后也会捆绑,以防万一很重要):
<MajorUpgrade DowngradeErrorMessage="A newer version is already installed."
Schedule="afterInstallExecute" />
<ComponentGroup Id="ServiceCG">
<Component Id="Service" Guid='*' Win64='yes' Directory='INSTALLDIR'>
<File Id='ServiceEXE' Source='$(var.root)Service.exe' />
<ServiceInstall Id="ServiceInstall"
Name="MyService"
DisplayName="My Server"
Type="ownProcess"
Start="auto"
ErrorControl="normal"
Description="My Server Service"
Interactive="no"
Account="[...]"
Password="[...]" />
<ServiceControl Id="StopService" Name="MyService" Start="install"
Stop="uninstall" Wait="yes" Remove="both" />
<util:User Id="UpdateServiceAccountLogonAsService" UpdateIfExists="yes"
CreateUser="no" Name="[SERVICEACCOUNTFULL]"
LogonAsService="yes"/>
</Component>
<Component Id="ServiceConfig" Guid='*' Win64='yes' Directory='INSTALLDIR'>
<File Id='FileServiceConfig' KeyPath='yes'
Source='$(var.root)Service.exe.config' />
</Component>
</ComponentGroup>
相关但未回答:
WiX 版本 3.8.1128.0