Wix卸载不会删除文件
问题描述:
我有一个带有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之一}存在
答
维克斯赢得不卸载它认为已经安装的组件,我认为这里就是这种情况。为什么?
- 可重复使用的GUID(确保它们都是唯一的)
- 可能是这个安装程序的早期版本标记这些组件为永久在一个点
然而,什么将你的代码除了我在这个问题上看到的类似问题,您没有任何File
元素作为组件KeyPath
列出。因此,我相信父目录默认情况下会成为KeyPath。 KeyPath用于确定组件是否安装在机器上。如果他们的KeyPath被设置为该目录,并且该目录已经存在,那么它可能在卸载时不会被删除,因为它已经安装。
作为最佳做法,请尝试在每个Component
中设置一个File
,并在File
元素集KeyPath="yes"
中尝试设置。
关于这一主题的类似问题:
答
我终于发现了事情的原委。我的安装工作正常,我在我的电脑上安装了应用程序应用程序。
最近,我修改了Drivers
目录的名称(而不是ID)。我已经重新安装我的应用程序(没有删除旧的),安装就OK了。之后,问题出现了。
解决方案很简单:
- 我消除了与Windows菜单应用(2个应用程序安装)
现在安装/卸载工作完美。
我已经看到了一些这些话题之前,但发出简化版,为我工作。经过一番调查,似乎我的问题很简单(我会添加答案) –