문제

내 응용 프로그램을 제거하면 구성하고 싶습니다. wix 추가 된 모든 파일을 제거하려면 설정합니다 원래 설치 후. Unstaller는 원래 MSI 파일에서 설치된 디렉토리 및 파일 만 제거하고 응용 프로그램 폴더에 나중에 추가 된 다른 모든 것을 남겨 두는 것 같습니다. 다른 말로, 나는 제거 할 때 디렉토리를 제거하고 싶습니다. 어떻게해야하나요?

도움이 되었습니까?

해결책

사용 removefile 요소 on = "제거". 예는 다음과 같습니다.

<Directory Id="CommonAppDataFolder" Name="CommonAppDataFolder">
  <Directory Id="MyAppFolder" Name="My">
    <Component Id="MyAppFolder" Guid="*">
      <CreateFolder />
      <RemoveFile Id="PurgeAppFolder" Name="*.*" On="uninstall" />
    </Component>
  </Directory>
</Directory>

업데이트

100%작동하지 않았습니다. 파일을 제거했지만 설치 후 생성 된 추가 디렉토리 중 어느 것도 제거되지 않았습니다. 그것에 대한 생각이 있습니까? - 프리 베이로

불행히도 Windows Installer는 하위 디렉토리로 디렉토리 삭제를 지원하지 않습니다. 이 경우 사용자 정의 액션에 의지해야합니다. 또는 하위 폴더가 무엇인지 아는 경우 removefolder를 만들고 제거 필수 요소를 만듭니다.

다른 팁

사용 RemoveFolderEx Wix의 Util Extension의 요소.
이 접근법을 사용하면 모든 하위 디렉토리도 제거됩니다 ( 사용 RemoveFile 직접 요소). 이 요소는 임시 행을 추가합니다 RemoveFile 그리고 RemoveFolder MSI 데이터베이스의 테이블.

이렇게하기 위해, 나는 단순히 제거 할 수있는 사용자 정의 액션을 만들었습니다.

Wix 코드는 다음과 같습니다.

<Binary Id="InstallUtil" src="InstallUtilLib.dll" />

<CustomAction Id="DIRCA_TARGETDIR" Return="check" Execute="firstSequence" Property="TARGETDIR" Value="[ProgramFilesFolder][Manufacturer]\[ProductName]" />
<CustomAction Id="Uninstall" BinaryKey="InstallUtil" DllEntry="ManagedInstall" Execute="deferred" />
<CustomAction Id="UninstallSetProp" Property="Uninstall" Value="/installtype=notransaction /action=uninstall /LogFile= /targetDir=&quot;[TARGETDIR]\Bin&quot; &quot;[#InstallerCustomActionsDLL]&quot; &quot;[#InstallerCustomActionsDLLCONFIG]&quot;" />

<Directory Id="BinFolder" Name="Bin" >
    <Component Id="InstallerCustomActions" Guid="*">
        <File Id="InstallerCustomActionsDLL" Name="SetupCA.dll" LongName="InstallerCustomActions.dll" src="InstallerCustomActions.dll" Vital="yes" KeyPath="yes" DiskId="1" Compressed="no" />
        <File Id="InstallerCustomActionsDLLCONFIG" Name="SetupCA.con" LongName="InstallerCustomActions.dll.Config" src="InstallerCustomActions.dll.Config" Vital="yes" DiskId="1" />
    </Component>
</Directory>

<Feature Id="Complete" Level="1" ConfigurableDirectory="TARGETDIR">
    <ComponentRef Id="InstallerCustomActions" />
</Feature>

<InstallExecuteSequence>
    <Custom Action="UninstallSetProp" After="MsiUnpublishAssemblies">$InstallerCustomActions=2</Custom>
    <Custom Action="Uninstall" After="UninstallSetProp">$InstallerCustomActions=2</Custom>
</InstallExecuteSequence>

installerCustomActions.dll의 onbeforeUninstall 메소드 코드는 VB에서 볼 수 있습니다.

Protected Overrides Sub OnBeforeUninstall(ByVal savedState As System.Collections.IDictionary)
    MyBase.OnBeforeUninstall(savedState)

    Try
        Dim CommonAppData As String = Me.Context.Parameters("CommonAppData")
        If CommonAppData.StartsWith("\") And Not CommonAppData.StartsWith("\\") Then
            CommonAppData = "\" + CommonAppData
        End If
        Dim targetDir As String = Me.Context.Parameters("targetDir")
        If targetDir.StartsWith("\") And Not targetDir.StartsWith("\\") Then
            targetDir = "\" + targetDir
        End If

        DeleteFile("<filename.extension>", targetDir) 'delete from bin directory
        DeleteDirectory("*.*", "<DirectoryName>") 'delete any extra directories created by program
    Catch
    End Try
End Sub

Private Sub DeleteFile(ByVal searchPattern As String, ByVal deleteDir As String)
    Try
        For Each fileName As String In Directory.GetFiles(deleteDir, searchPattern)
            File.Delete(fileName)
        Next
    Catch
    End Try
End Sub

Private Sub DeleteDirectory(ByVal searchPattern As String, ByVal deleteDir As String)
    Try
        For Each dirName As String In Directory.GetDirectories(deleteDir, searchPattern)
            Directory.Delete(dirName)
        Next
    Catch
    End Try
End Sub

다음은 @Tronda의 제안에 대한 변형입니다. 제거하는 동안 다른 사용자 정의 작업으로 생성되는 "install.log"파일을 삭제하고 있습니다.

<Product>
    <CustomAction Id="Cleanup_logfile" Directory="INSTALLFOLDER"
    ExeCommand="cmd /C &quot;del install.log&quot;"
    Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />

    <InstallExecuteSequence>
      <Custom Action="Cleanup_logfile" Before="RemoveFiles" >
        REMOVE="ALL"
      </Custom>
    </InstallExecuteSequence>
</Product>

내가 이해하는 한,이 파일은 설치 후 생성되며 구성 요소 그룹의 일부가 아니기 때문에 "removefile"을 사용할 수 없습니다.

WIX 전문가는 아니지만 이에 대한 가능한 (간단한?) 솔루션이 조용한 실행 커스텀 액션 WIX의 내장 연장의 일부는 무엇입니까?

실행할 수 있습니다 rmdir /s 및 /q 옵션이있는 MS DOS 명령.

<Binary Id="CommandPrompt" SourceFile="C:\Windows\System32\cmd.exe" />

작업을 수행하는 사용자 정의 액션은 간단합니다.

<CustomAction Id="DeleteFolder" BinaryKey="CommandPrompt" 
              ExeCommand='/c rmdir /S /Q "[CommonAppDataFolder]MyAppFolder\PurgeAppFolder"' 
              Execute="immediate" Return="check" />

그런 다음 여러 곳에서 문서화 된대로 Installexecutesequence를 수정해야합니다.

업데이트:이 접근법에 문제가있었습니다. 결국 사용자 정의 작업을 수행했지만 여전히이를 실행 가능한 솔루션으로 간주하지만 세부 사항은 작동하지 않습니다.

이것은 더 완전한 대답이 될 것입니다 @pavel 제안, 나에게 100%작동합니다.

<Fragment Id="FolderUninstall">
    <?define RegDir="SYSTEM\ControlSet001\services\[Manufacturer]:[ProductName]"?>
    <?define RegValueName="InstallDir"?>
    <Property Id="INSTALLFOLDER">
        <RegistrySearch Root="HKLM" Key="$(var.RegDir)" Type="raw" 
                  Id="APPLICATIONFOLDER_REGSEARCH" Name="$(var.RegValueName)" />
    </Property>

    <DirectoryRef Id='INSTALLFOLDER'>
        <Component Id="UninstallFolder" Guid="*">
            <CreateFolder Directory="INSTALLFOLDER"/>
            <util:RemoveFolderEx Property="INSTALLFOLDER" On="uninstall"/>
            <RemoveFolder Id="INSTALLFOLDER" On="uninstall"/>
            <RegistryValue Root="HKLM" Key="$(var.RegDir)" Name="$(var.RegValueName)" 
                    Type="string" Value="[INSTALLFOLDER]" KeyPath="yes"/>
        </Component>
    </DirectoryRef>
</Fragment>

그리고 제품 요소 아래 :

<Feature Id="Uninstall">
    <ComponentRef Id="UninstallFolder" Primary="yes"/>
</Feature>

이 접근법은 폴더의 원하는 경로를 사용하여 제거 할 때 삭제할 수있는 레지스트리 값을 설정합니다. 결국, 설치 폴더와 레지스트리 폴더 모두 시스템에서 제거됩니다. 레지스트리로가는 경로는 다른 하이브 및 기타 위치에있을 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top