簡體   English   中英

在MSI安裝程序中更新服務名稱並重新安裝/升級時出錯

[英]Error when updated service name in MSI Installer and Reinstalled/Upgraded

我有一個安裝某些服務的MSI。 我更改了其中之一的名稱,並更新了Wix文件中的引用。

當我將其安裝為新的MSI時,它可以正常工作。 但是,當存在升級方案(使用舊的服務名稱安裝MSI,並且我嘗試安裝服務名稱已更改的新MSI)時,出現以下錯誤:

錯誤

這里有什么提示嗎? 我只是在.wxs文件中重命名。 我是否必須卸載具有現有組件ID的舊組件並使用新組件ID命名新的組件?

當前,使用帶有新名稱的舊組件ID。

舊代碼的某些部分:

<Directory Id="dirxxx" Name="oldname">
                <!-- oldname service-->
              <Component Id="cmpOldNameService" Guid="bbb"
                  SharedDllRefCount="no" KeyPath="no" NeverOverwrite="no" Permanent="no" Transitive="no"
                  Win64="no" Location="either">
              <RemoveFile Id="ccc" On="uninstall" Name="z.dll"/>
              <File Id="ccc" KeyPath="no" Source="$(var.xSource)\OldNameService\a.dll"/>
              <File Id="ddd" KeyPath="no" Source="$(var.xSource)\OldNameService\b.dll"/>
              <File Id="eee" KeyPath="no" Source="$(var.xSource)\OldNameService\c.dll"/>
              <File Id="fff" KeyPath="no" Source="$(var.xSource)\OldNameService\d.dll"/>
              <File Id="ggg" KeyPath="no" Source="$(var.xSource)\OldNameService\e.dll"/>
              <File Id="hhh" KeyPath="no" Source="$(var.xSource)\OldNameService\f.dll"/>
              <File Id="iii" KeyPath="yes" Source="$(var.xSource)\OldNameService\g.exe"/>
              <File Id="jjj" KeyPath="no" Source="$(var.xSource)\OldNameService\h.dll"/>
              <File Id="kkk" KeyPath="no" Source="$(var.xSource)\OldNameService\i.dll"/>
              <ServiceInstall Id="OldNameService" DisplayName="OldName Service" Name="NewName"
                ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes" Description="OldName Service">
                <ServiceConfig DelayedAutoStart="yes" OnInstall="yes" OnReinstall="yes"/>
              </ServiceInstall>

              <ServiceControl Id="OldNameServiceControl" Name="NewName"
                Start="install" Stop="uninstall" Remove="uninstall" Wait="no"/>

            </Component>

              <Component Id="lll" Guid="mmm" NeverOverwrite="yes">
                <File Id="nnn" KeyPath="yes" Source="$(var.xSource)\OldNameService\OldName.exe.config"/>
                <util:XmlFile Id="UpdateOldNamelogFileName"
                              File="[#nnn]"
                              Action="setValue"
                              ElementPath="/configuration/appSettings/add[\[]@key='logFile'[\]]/@value"
                              Value="[ooo]oldname_YYYYMM.log" />
              </Component>

替換為新代碼:

<Directory Id="dirxxx" Name="newname">
                <!-- newname service-->
              <Component Id="cmpNewNameService" Guid="bbb"
                  SharedDllRefCount="no" KeyPath="no" NeverOverwrite="no" Permanent="no" Transitive="no"
                  Win64="no" Location="either">
              <RemoveFile Id="ccc" On="uninstall" Name="z.dll"/>
              <File Id="ccc" KeyPath="no" Source="$(var.xSource)\NewNameService\a.dll"/>
              <File Id="ddd" KeyPath="no" Source="$(var.xSource)\NewNameService\b.dll"/>
              <File Id="eee" KeyPath="no" Source="$(var.xSource)\NewNameService\c.dll"/>
              <File Id="fff" KeyPath="no" Source="$(var.xSource)\NewNameService\d.dll"/>
              <File Id="ggg" KeyPath="no" Source="$(var.xSource)\NewNameService\e.dll"/>
              <File Id="hhh" KeyPath="no" Source="$(var.xSource)\NewNameService\f.dll"/>
              <File Id="iii" KeyPath="yes" Source="$(var.xSource)\NewNameService\g.exe"/>
              <File Id="jjj" KeyPath="no" Source="$(var.xSource)\NewNameService\h.dll"/>
              <File Id="kkk" KeyPath="no" Source="$(var.xSource)\NewNameService\i.dll"/>
              <ServiceInstall Id="NewNameService" DisplayName="NewName Service" Name="NewName"
                ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes" Description="New Name Service">
                <ServiceConfig DelayedAutoStart="yes" OnInstall="yes" OnReinstall="yes"/>
              </ServiceInstall>

              <ServiceControl Id="NewNameServiceControl" Name="NewName"
                Start="install" Stop="uninstall" Remove="uninstall" Wait="no"/>

            </Component>

              <Component Id="lll" Guid="mmm" NeverOverwrite="yes">
                <File Id="nnn" KeyPath="yes" Source="$(var.xSource)\NewNameService\NewName.exe.config"/>
                <util:XmlFile Id="UpdateNewNamelogFileName"
                              File="[#nnn]"
                              Action="setValue"
                              ElementPath="/configuration/appSettings/add[\[]@key='logFile'[\]]/@value"
                              Value="[ooo]newservice_YYYYMM.log" />
              </Component>

這太長了,無法添加為評論,我添加為答案,盡管它可能無法為您解答:

  • 最明顯的“錯誤”或至少是非標准問題是,單個組件中有很多二進制文件。 不是最佳做法 (實際上是非常不好的做法)。
  • 在執行其他任何操作之前,請拆分您的組件並為每個文件創建一個組件 我總是為每個組件使用單個文件,即使對於非二進制文件也是如此,但是最佳實踐指出,對於二進制文件,應始終使用單獨的組件。 本質上,這是正確部署的要求。
  • 簡而言之:如果將多個文件保留在同一組件中,則其中只有一個是密鑰文件。 如果該文件的版本號沒有增加(對於二進制文件),則其他所有文件也不會更新-即使它們的版本已增加。 只有密鑰文件才能確定是否已安裝組件。 而且一個組件只能整體安裝或根本不安裝。
  • 對於非版本化文件,事情以類似的方式工作,但是不是檢查版本,而是檢查文件是否已被修改。 如果磁盤上的文件已被修改,則安裝該組件。 在MSDN文章文件版本控制規則中閱讀更多內容。 您也可以在同一問題上查看此Symantec文章 這個問題的答案值得一讀(以及Chris Painter的評論): 當兩個組件都沒有密鑰文件時的文件版本控制規則
  • 如果您的應用程序具有“ 實時版本 ”,我將對主要安裝進行升級 ,並在InstallExecuteSequence的早期進行計划。 用簡單的英語來說,這意味着您將在安裝新版本之前完全卸載以前的版本。 這樣可以消除組件創建錯誤或其他錯誤之后的所有錯誤。 我沒有讀得太透徹,但是這個答案(第一個答案)似乎可以很好地說明如何安排大型升級: 如何使WiX大型升級正常工作? 或直接獲取源代碼,並查看WiX 3文檔以了解如何實施主要升級 ,而為了很好地采取措施,我提供了此鏈接: 如何實施WiX安裝程序升級?
  • 除了所有這些,我還建議您按照此答案中的說明“簡化”您的WiX XML: WIX中GUID的語法? 定義的屬性越少,越容易讀取文件內容,隱藏的錯誤也越少(以后以XML格式升級可能會更容易)。
  • 請嘗試此“組件修復”並進行重大升級調整,以查看這是否可以解決您的問題。 並嘗試簡化源代碼

這樣我就能在這里解決我的問題。 我想進行小規模升級,並在ServiceInstall中將Account屬性添加為Network Service

<ServiceInstall Id="Service1" DisplayName="My Service" Name="MyService"
                    ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes" Description="My Service" Account="NT Authority\NetworkService">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM