2017-09-13 170 views
0

我有一個帶有WiX安裝程序的C#項目。Wix卸載不會刪除文件

當我安裝我的應用程序時,所有工作。我有:

  • 我的compagny文件夾在程序文件(x86),包含我的應用程序文件夾和驅動程序文件夾。
  • 快捷桌面
  • 快捷在開始菜單

當安裝應用程序,我可以運行我的MSI和我有一個選項來卸載。但是當我卸載我的應用程序時,只有驅動程序文件夾被刪除(MyApplication_Drivers)。我仍然有我的應用程序文件夾和快捷方式。

我失蹤了什麼?

還有就是我的product.wxs代碼(全部代碼,因爲我不知道從哪兒來的問題):

<?xml version="1.0" encoding="UTF-8"?> 
<?define compagny = "My compagny"?> 
<?define product = "MyApplication"?> 
<?define version = "!(bind.FileVersion.MyApplication.exe)"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <Product Id="*" 
      Name="$(var.product)" 
      Language="1033" 
      Version="$(var.version)" 
      Manufacturer="$(var.compagny)" 
      UpgradeCode="***"> 
     <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> 
     <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 
    <Media Id="1" Cabinet="MyApplication.cab" EmbedCab="yes"/> 

    <Feature Id="ProductFeature" Title="$(var.product)" Level="1"> 
     <ComponentGroupRef Id="ProductComponents"/> 
     <ComponentRef Id ="InstallFonts" /> 
     <ComponentRef Id ="ApplicationShortcut"/> 
     <ComponentRef Id ="ApplicationShortcutDesk"/> 
    </Feature> 

    <Property Id="WIXUI_INSTALLDIR" Value="COMPAGNYFOLDER"/>  

    <WixVariable Id="WixUIBannerBmp" 
       Value=".\Images\WixUIBannerBmp.bmp"/> 
    <WixVariable Id="WixUIDialogBmp" 
       Value=".\Images\WixUIDialogBmp.bmp"/> 

    <UI> 
     <UIRef Id="WixUI_Custom"/>  

     <Publish Dialog="WelcomeDlg" 
       Control="Next" 
       Event="NewDialog" 
       Value="InstallDirDlg" 
       Order="2">1</Publish> 

     <Publish Dialog="InstallDirDlg" 
       Control="Back" 
       Event="NewDialog" 
       Value="WelcomeDlg" 
       Order="2">1</Publish> 
    </UI> 
    </Product> 

    <Fragment> 
    <Directory Id="TARGETDIR" Name="SourceDir"> 
     <Directory Id="FontsFolder" /> 

     <Directory Id="ProgramMenuFolder"> 
     <Directory Id="ApplicationProgramsFolder" Name="$(var.compagny)"/> 
     </Directory> 

     <Directory Id="DesktopFolder" SourceName="Desktop"/> 

     <Directory Id="ProgramFilesFolder"> 
     <Directory Id="COMPAGNYFOLDER" Name="$(var.compagny)"> 
      <Directory Id="INSTALLFOLDER" Name="$(var.product)"> 
      <Directory Id="fr" Name="fr"/> 
      <Directory Id="SETTINGS" Name="Settings"> 
       <Directory Id="PRINTERS" Name="Printers"/> 
      </Directory> 
      </Directory> 
      <Directory Id="Drivers" Name="MyApplication_Drivers"/> 
     </Directory> 
     </Directory> 
    </Directory> 
    </Fragment> 

    <Fragment> 
    <DirectoryRef Id="ApplicationProgramsFolder"> 
     <Component Id="ApplicationShortcut" Guid="***"> 
     <Shortcut Id="ApplicationStartMenuShortcut" 
        Name="$(var.product)" 
        Description="$(var.product) application" 
        Target="[#MyApplication.exe]" 
        WorkingDirectory="INSTALLFOLDER"/> 
     <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/> 
     <RegistryValue Root="HKCU" Key="SOFTWARE\$(var.compagny)\$(var.product)" Name="installedStart" Type="integer" Value="1" KeyPath="yes"/> 
     </Component> 
    </DirectoryRef> 

    <DirectoryRef Id="DesktopFolder"> 
     <Component Id="ApplicationShortcutDesk" Guid="***"> 
     <Shortcut Id="ApplicationStartDeskShortcut" 
        Name="$(var.product)" 
        Description="$(var.product) application" 
        Target="[#MyApplication.exe]" 
        WorkingDirectory="INSTALLFOLDER"/> 
     <RemoveFolder Id="DesktopFolder" On="uninstall"/> 
     <RegistryValue Root="HKCU" Key="SOFTWARE\$(var.compagny)\$(var.product)" Name="installedDesk" Type="integer" Value="1" KeyPath="yes"/> 
     </Component> 
    </DirectoryRef> 

    <DirectoryRef Id="FontsFolder"> 
     <Component Id="InstallFonts" Guid="{***}" Permanent="yes"> 
     <File Id="OCRB_Medium.ttf" Source="$(var.SolutionDir)_Required\OCRB_Medium.ttf" TrueType="yes" /> 
     <File Id="OCRBS___.TTF" Source="$(var.SolutionDir)_Required\OCRBS___.TTF" TrueType="yes" /> 
     </Component> 
    </DirectoryRef> 
    </Fragment> 

    <Fragment> 
    <ComponentGroup Id="ProductComponents"> 
     <!-- Application --> 
     <Component Id="ProductComponent" Guid="{***}" Directory="INSTALLFOLDER" UninstallWhenSuperseded="yes"> 
     <!-- DLL --> 
     <File Id="Bitmap.Core.dll" Source="$(var._Delivery.TargetDir)..\bin\Bitmap.Core.dll"/> 
     <File Id="PdfLib.dll" Source="$(var._Delivery.TargetDir)..\bin\PdfLib.dll"/> 

     <!-- EXE --> 
     <File Id="MyApplication.exe" Source="$(var._Delivery.TargetDir)..\bin\MyApplication.exe"/> 
     <File Id="MyApplication.exe.config" Source="$(var._Delivery.TargetDir)..\bin\MyApplication.exe.config"/> 
     </Component> 

     <!-- fr --> 
     <Component Id="FRComponent" Guid="{***}" Directory="fr" UninstallWhenSuperseded="yes"> 
     <File Id="resources-fr.dll" Source="$(var._Delivery.TargetDir)..\bin\fr\resources-fr.dll" /> 
     </Component> 

     <!-- Settings --> 
     <Component Id="SetComponent" Guid="{***}" Directory="SETTINGS" UninstallWhenSuperseded="yes"> 
     <File Id="Settings.xml" Source="$(var.MyApplication.ProjectDir)Settings\Settings.xml" /> 
     </Component> 

     <!-- Printers --> 
     <Component Id="PrintComponent" Guid="{***}" Directory="PRINTERS" UninstallWhenSuperseded="yes"> 
     <File Id="Sticker.xml" Source="$(var.MyApplication.ProjectDir)Settings\Printers\Sticker.xml" /> 
     </Component> 

     <!-- Resources --> 
     <Component Id="Drivers" Guid="{***}" Directory="Drivers" UninstallWhenSuperseded="yes"> 
     <File Id="drivers.exe" Source="$(var.SolutionDir)_Required\drivers.exe"/> 
     <File Id="user_manual_E.pdf" Source="$(var.SolutionDir)_Required\user_manual_E.pdf"/> 
     </Component> 
     </ComponentGroup> 
    </Fragment> 
</Wix> 

編輯:

  • 舊版本的代碼是完美的工作

  • 我打印日誌時卸載和此行似乎與此問題有關:

MSI(C)(E8:BC)[10:58:16:769]:如果不允許 成分的卸載:自另一端{我的GUID之一}存在

回答

1

維克斯贏得不卸載它認爲已經安裝的組件,我認爲這裏就是這種情況。爲什麼?

  • 可重複使用的GUID(確保它們都是唯一的)
  • 可能是這個安裝程序的早期版本標記這些組件爲永久在一個點

然而,什麼將你的代碼除了我在這個問題上看到的類似問題,您沒有任何File元素作爲組件KeyPath列出。因此,我相信父目錄默認情況下會成爲KeyPath。 KeyPath用於確定組件是否安裝在機器上。如果他們的KeyPath被設置爲該目錄,並且該目錄已經存在,那麼它可能在卸載時不會被刪除,因爲它已經安裝。

作爲最佳做法,請嘗試在每個Component中設置一個File,並在File元素集KeyPath="yes"中嘗試設置。

關於這一主題的類似問題:

+0

我已經看到了一些這些話題之前,但發出簡化版,爲我工作。經過一番調查,似乎我的問題很簡單(我會添加答案) –

0

我終於發現了事情的原委。我的安裝工作正常,我在我的電腦上安裝了應用程序應用程序。

最近,我修改了Drivers目錄的名稱(而不是ID)。我已經重新安裝我的應用程序(沒有刪除舊的),安裝就OK了。之後,問題出現了。

解決方案很簡單:

  • 我消除了與Windows菜單應用(2個應用程序安裝)

現在安裝/卸載工作完美。

相關問題