2017-08-22 136 views
0

我试图卸载一个已安装的服务,该服务有几个组件,但无法安装。 任何人都可以请帮我卸载标签吗?我做了很多搜索,但无法成功运行任何东西。如何在下次升级时完全从应用程序中卸载服务,这不是主要升级

只需将ServiceControl标签和删除所有组件工作?我试过但没有工作。你如何处理组件和依赖关系?需要逻辑和语法帮助。

以下是我在前一版本中安装该服务的代码。请让我知道我必须添加的标签才能将其删除。

<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> 



<!--Recovery-Interval needs to be added in both cases new install as well as upgrades-->  


        <Component Id="qqq" Guid="r-r-r-r-r" NeverOverwrite="yes"> 
         <Condition><![CDATA[INSTALDIR <> "" AND NOT REMOVE AND POSTV1 = ""]]></Condition> 
         <CreateFolder /> 

         <util:XmlConfig Id="RecoveryInterval" Action="create" ElementPath="config/settings" File="[INSTALDIR]\oldname\OldNameService.exe.config" Node="element" On="install" Name="add" Sequence="1"> 
          <util:XmlConfig Id="RecoveryInterval2" ElementId="RecoveryInterval" Name="key" Value="Recovery-Interval" File="[INSTALDIR]\oldname\OldNameService.exe.config" /> 
          <util:XmlConfig Id="RecoveryInterval3" ElementId="RecoveryInterval" Name="value" Value="3600" File="[INSTALDIR]\oldname\OldNameService.exe.config" /> 
         </util:XmlConfig> 
        </Component> 

        <!-- Analytics--> 
        <Component Id="eee" Guid="f-f-f-f-f" NeverOverwrite="yes"> 
         <Condition><![CDATA[(INSTALDIR <> "") AND NOT REMOVE]]></Condition> 
         <CreateFolder />       
         <!-- Analytics--> 
         <util:XmlConfig Id="EnableAnalytics" Action="create" ElementPath="config/settings" File="[INSTALDIR]\oldname\OldNameService.exe.config" Node="element" On="install" Name="add" VerifyPath="/config/settings/add[\[]@key='EnableAnalytics'[\]]"> 
          <util:XmlConfig Id="EnableAnalytics2" ElementId="EnableAnalytics" Name="key" Value="VEnableAnalytics" File="[INSTALDIR]\oldname\OldNameService.exe.config" /> 
          <util:XmlConfig Id="EnableAnalytics3" ElementId="EnableAnalytics" Name="value" Value="1" File="[INSTALDIR]\oldname\OldNameService.exe.config" /> 
         </util:XmlConfig> 

         <util:XmlConfig Id="AnalyticsTrackingId" Action="create" ElementPath="config/settings" File="[INSTALDIR]\oldname\OldNameService.exe.config" Node="element" On="install" Name="add" VerifyPath="/config/settings/add[\[]@key='AnalyticsTrackingId'[\]]"> 
          <util:XmlConfig Id="AnalyticsTrackingId2" ElementId="AnalyticsTrackingId" Name="key" Value="AnalyticsTrackingId" File="[INSTALDIR]\oldname\OldNameService.exe.config" /> 
          <util:XmlConfig Id="AnalyticsTrackingId3" ElementId="AnalyticsTrackingId" Name="value" Value="YwByAE3eVweXAAcAVwBasBUAAgAMsB0AAwAbzz==" File="[INSTALDIR]\oldname\OldNameService.exe.config" /> 
         </util:XmlConfig> 
        </Component> 

        <!-- Added to handle upgrade scenario for assembly binding redirect for Newtonsoft.json --> 
        <Component Id="cmpNewtonsoftVersionUpgrade" Guid="{a-60CA-d-w-f}" NeverOverwrite="yes"> 
         <Condition><![CDATA[(INSTALDIR <> "") AND NOT REMOVE]]></Condition> 
         <CreateFolder/> 
         <util:XmlConfig Id="AddRuntimeElement" 
             File="[INSTALDIR]\oldname\OldNameService.exe.config" 
             Action="create" Node="element" Name="runtime" On="install" 
             ElementPath="configuration" 
             VerifyPath="/configuration/runtime/assemblyBinding/dependentAssembly/assemblyIdentity[\[]@name='Newtonsoft.Json'[\]]" 
             Sequence="1" /> 
         <util:XmlConfig Id="AddAssemblyBindingElement" 
             File="[INSTALDIR]\oldname\OldNameService.exe.config" 
             Action="create" Node="element" Name="assemblyBinding" On="install" ElementPath="configuration/runtime" 
             VerifyPath="/configuration/runtime/assemblyBinding/dependentAssembly/assemblyIdentity[\[]@name='Newtonsoft.Json'[\]]" 
             Sequence="2"/> 
         <util:XmlConfig Id="AddDependentAssemblyElement" 
             File="[INSTALDIR]\oldname\OldNameService.exe.config" 
             Action="create" Node="element" Name="dependentAssembly" On="install" 
             ElementPath="configuration/runtime/assemblyBinding" 
             VerifyPath="/configuration/runtime/assemblyBinding/dependentAssembly/assemblyIdentity[\[]@name='Newtonsoft.Json'[\]]" 
             Sequence="3"/> 
         <util:XmlConfig Id="AddAssemblyIdentityElement" 
             File="[INSTALDIR]\oldname\OldNameService.exe.config" 
             Action="create" Node="element" Name="assemblyIdentity" On="install" 
             ElementPath="configuration/runtime/assemblyBinding/dependentAssembly" 
             VerifyPath="/configuration/runtime/assemblyBinding/dependentAssembly/assemblyIdentity[\[]@name='Newtonsoft.Json'[\]]" 
             Sequence="4"> 
          <util:XmlConfig Id="AddNameKey" 
              File="[INSTALDIR]\oldname\OldNameService.exe.config" 
              ElementId="AddAssemblyIdentityElement" Name="name" Value="Newtonsoft.Json" /> 
          <util:XmlConfig Id="AddPublicKeyToken" 
              File="[INSTALDIR]\oldname\OldNameService.exe.config" 
              ElementId="AddAssemblyIdentityElement" Name="publicKeyToken" Value="30ad4fe6b2a6aeed" /> 
          <util:XmlConfig Id="AddCulture" 
              File="[INSTALDIR]\oldname\OldNameService.exe.config" 
              ElementId="AddAssemblyIdentityElement" Name="culture" Value="neutral" /> 
          <util:XmlConfig Id="AddXmlnsOnAssemblyIdentity" 
              File="[INSTALDIR]\oldname\OldNameService.exe.config" 
              ElementId="AddAssemblyIdentityElement" Name="xmlns" Value="urn:schemas-microsoft-com:asm.v1" /> 
         </util:XmlConfig> 
         <util:XmlConfig Id="DeleteBindingRedirectElement" 
             File="[INSTALDIR]\oldname\OldNameService.exe.config" 
             Action="delete" Node="element" Name="bindingRedirect" On="install" 
             ElementPath="configuration/runtime/assemblyBinding/dependentAssembly[\[]assemblyIdentity[\[]@name='Newtonsoft.Json'[\]][\]]" 
             VerifyPath="/configuration/runtime/assemblyBinding/dependentAssembly/bindingRedirect[\[]@oldVersion='0.0.0.0-6.0.0.0'[\]]" 
             Sequence="5" /> 
         <util:XmlConfig Id="DeleteBindingRedirectElementoldserviceOnv4" 
             File="[INSTALDIR]\oldname\OldNameService.exe.config" 
             Action="delete" Node="element" Name="bindingRedirect" On="install" 
             ElementPath="configuration/runtime/assemblyBinding/dependentAssembly[\[]assemblyIdentity[\[]@name='Newtonsoft.Json'[\]][\]]" 
             VerifyPath="/configuration/runtime/assemblyBinding/dependentAssembly/bindingRedirect[\[]@oldVersion='0.0.0.0-8.0.0.0'[\]]" 
             Sequence="6" /> 
         <util:XmlConfig Id="AddBindingRedirectElement" 
             File="[INSTALDIR]\oldname\OldNameService.exe.config" 
             Action="create" Node="element" Name="bindingRedirect" On="install" 
             ElementPath="configuration/runtime/assemblyBinding/dependentAssembly[\[]assemblyIdentity[\[]@name='Newtonsoft.Json'[\]][\]]" 
             VerifyPath="/configuration/runtime/assemblyBinding/dependentAssembly/bindingRedirect[\[]@oldVersion='0.0.0.0-9.0.0.0'[\]]" 
             Sequence="7"> 
          <util:XmlConfig Id="AddOldVersionKey" 
              File="[INSTALDIR]\oldname\OldNameService.exe.config" 
              ElementId="AddBindingRedirectElement" Name="oldVersion" Value="0.0.0.0-9.0.0.0" /> 
          <util:XmlConfig Id="AddNewVersionKeyS3Uploader" 
              File="[INSTALDIR]\oldname\OldNameService.exe.config" 
              ElementId="AddBindingRedirectElement" Name="newVersion" Value="9.0.0.0" /> 
          <util:XmlConfig Id="AddXmlnsOnBindingRedirectS3Uploader" 
              File="[INSTALDIR]\oldname\OldNameService.exe.config" 
              ElementId="AddBindingRedirectElement" Name="xmlns" Value="urn:schemas-microsoft-com:asm.v1" /> 
         </util:XmlConfig> 
         <util:XmlConfig Id="AddNameSpaceToyElement" 
             File="[INSTALDIR]\oldname\OldNameService.exe.config" 
             Action="create" Node="value" Name="xmlns" Value="urn:schemas-microsoft-com:asm.v1" On="install" 
             ElementPath="/configuration/runtime/assemblyBinding" 
             Sequence="8" /> 
         <util:XmlConfig Id="AddNameSpaceToDependentAssemblyElement" 
             File="[INSTALDIR]\oldname\OldNameService.exe.config" 
             Action="create" Node="value" Name="xmlns" Value="urn:schemas-microsoft-com:asm.v1" On="install" 
             ElementPath="/configuration/runtime/assemblyBinding/dependentAssembly[\[]assemblyIdentity[\[]@name='Newtonsoft.Json'[\]][\]]" 
             Sequence="9" /> 

        </Component> 
</Directory> 

实施例试验为1个组分:

<Component Id="cmpoldNameService" Guid="9-kj-4509-ko-B4F7700AFDCE" 
           SharedDllRefCount="no" KeyPath="no" NeverOverwrite="no" Permanent="no" Transitive="yes" 
           Win64="no" Location="either"> 
          <Condition>FALSE</Condition> 
          <RemoveFolder Id="diytg" On="uninstall"/> 
          <RemoveFile Id="ghgj" On="uninstall" Name="a.dll"/> 
          <RemoveFile Id="uiu" On="uninstall" Name="b.dll"/> 
          <RemoveFile Id="hujhjn" On="uninstall" Name="c.dll"/> 
          <RemoveFile Id="okl" On="uninstall" Name="d.dll"/> 
          <RemoveFile Id="bbb" On="uninstall" Name="e.dll"/> 
          <RemoveFile Id="bbbb" On="uninstall" Name="f.dll"/> 
          <RemoveFile Id="kkkl" On="uninstall" Name="g.dll"/> 
          <RemoveFile Id="mmmm" On="uninstall" Name="h.dll"/> 
          <RemoveFile Id="nnn" On="uninstall" Name="i.exe"/> 
          <RemoveFile Id="bboo" On="uninstall" Name="j.dll"/> 
          <RemoveFile Id="ttt" On="uninstall" Name="k.dll"/> 

          <ServiceControl Id="OldNameServiceControl" Name="OldName" 
              Start="install" Stop="both" Remove="both" Wait="yes"/> 

         </Component> 

回答

2

MSI次要升级不能正式除去组件或特征。解决方法(Hack)是保留原始组件,但为它们提供一个零字节文件,并将Revaluate属性(MSI中的可传递位)设置为true,并为其提供一个始终评估为false的条件。这种方式Windows安装程序将此组件转换为未安装,并停止并删除该服务。

你将不得不保留这个0字节的假组件,直到你做下一次主要升级。然后它可以被删除。

说实话,小升级是非常挑剔的,如果你还不知道这些规则,你可能会更好地服务于总是进行重大升级,直到你做。如果你愿意,小升级可能会让你非常难过。

+0

感谢您的回复。你可以给一个组件的示例代码。我是否必须包含文件以及新版本中指向路径的那些文件,这些文件将被删除。所以这里的用例是我正在重命名现有的服务。我尝试了重命名,但它不起作用,因此我正在卸载现有的一个,并将重命名的一个安装为新的GUIDS。 – Atihska

+0

您需要提供您的wix构建一个零字节文件的相同名称,以便该组件仍然有效并编译。您必须为新服务创建一个新的组件。它并没有被重新命名,但旧的被删除,并添加了新的。 –

+0

检查我的编辑。我为一个组件添加了一个代码。你能否验证这是否正确,我必须为所有组件做到这一点? – Atihska