使wintoolset在卸载后不删除文件后,如何使它们再次可卸载?

时间:2019-07-04 13:54:09

标签: c# wix

我使用以下代码使文件在卸载期间不会被删除:

  <Condition Level="0">
    <![CDATA[REMOVE = "ALL"]]>
  </Condition>

但是我猜想,因为我将它放在与其他文件相同的文件中,所以其他文件也无法卸载。

<Feature Id="Config_File" Title="Configuration File" Level="1">
  <ComponentRef Id="ProductComponents" />
  <ComponentRef Id="Executable" />     
  <ComponentRef Id="Config_File" />
  <Condition Level="0">
    <![CDATA[REMOVE = "ALL"]]>
  </Condition>
</Feature>

... 对于不希望在卸载过程中删除的文件,我还设置了Permanent标签为“ yes”:

<Component Id="Config_File" Guid="*" Permanent="yes" NeverOverwrite="yes">
   <File Id="ApplicationConfigFile" Name="application.config" Source=".\application.config" Vital="yes" />
</Component>

我的问题是:如何再次使这些文件无法安装?

  • 将条件中的“级别”设置为“ 0”也不起作用。
  • 将“永久”设置为“否”无效。

                 

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <!--MediaTemplate /-->
    
    <Media Id="1" Cabinet="SOPHATEL_Server_Management.cab" EmbedCab="yes" />
    
        <Feature Id="ProductFeature" Title="SOPHATEL Server Management" Level="1">
            <!--ComponentGroupRef Id="ProductComponents" /-->
      <ComponentRef Id="ProductComponents" />
      <ComponentRef Id="ProductComponents2" />
      <ComponentRef Id="Executable" />     
        </Feature>
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
    

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER" Name="SOPHATEL Server Management" />
            </Directory>
        </Directory>
    </Fragment>
    
    <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
    
      <Component Id="ProductComponents" Guid="f5207608-9c81-4317-89de-061066ec863c">
        <File Id="WebAPISelfHostingExe" Name="WebAPISelfHosting.exe" Source="..\WebAPISelfHosting\bin\Debug\WebAPISelfHosting.exe" Vital="yes" />
      </Component>
    
      <Component Id="ProductComponents2" Guid="f5207608-9c81-4317-89de-061066ec863d" NeverOverwrite="yes">
        <File Id="configFile" Name="application.config" Source=".\application.config" Vital="yes" />
      </Component>
    
      <!--Component Id="icon.ico" Guid="7805267a-624b-41e7-baaf-49b82c0439cc">
        <File Id='icon.ico' Name='icon.ico' Source="..\WixInstall\icon.ico" KeyPath='yes' />
      </Component-->
    
      <Component Id="Executable" Guid="f5207608-9c81-4317-89de-061066ec863e">
        <File Id="Service_testExe" Name="Service_test.exe" Source="..\Service_test\bin\Debug\Service_test.exe" Vital="yes" />
        <!-- Remove all files from the INSTALLFOLDER on uninstall -->
        <RemoveFile Id="ALLFILES" Name="*.*" On="both" />
        <!-- Remove INSTALLFOLDER on uninstall -->
        <RemoveFolder Id="INSTALLDIR" On="uninstall" />
        <!-- Tell WiX to install the Service -->        
        <ServiceInstall 
        Id="ServiceInstaller" 
        Type="ownProcess" 
        Name="Service_test" 
        DisplayName="Service_test"
        Description="A Test Service that logs dummy text on an interval to a text file." 
        Start="auto" 
        ErrorControl="normal" />
        <!-- Tell WiX to start the Service -->
        <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="Service_test" Wait="yes" />
    
    </Component>
    </ComponentGroup>
    

所有文件现在无法卸载,我想再次被卸载。

1 个答案:

答案 0 :(得分:0)

更改GUID对我有用。我放入了新的GUID,现在可以卸载文件了。