我很努力讓MajorUpgrade,ServiceControl,.config文件很好地一起工作。 After my other question,我現在有點反過來了。WiX重大升級的Windows服務,保存.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
您使用的是哪個版本的wix?知道這可能會幫助你得到有用的答案。 –
WiX版本3.8.1128.0 –
WiX版本與此問題無關。涉及的所有元素都映射到Windows Installer表並且沒有其他自定義擴展。這是MSI潛在的行爲,這很重要。 –