我已经创建了我的第一个Wix设置到我的C#项目中(我对wix不太熟悉)。
该设置创建了一个MSI文件,该文件运行良好。安装完成后,所有的DLL和.EXE文件都被创建在“C:\Program Files (x86)\MyApplication”目录下。
但是当我右键点击MSI并选择卸载时,虽然显示了一个无误的卸载菜单,但是"C:\Program Files (x86)\MyApplication"文件夹没有被删除。
如何定义卸载功能以删除此文件夹?
以下是我的Product.wxs一部分内容:
该设置创建了一个MSI文件,该文件运行良好。安装完成后,所有的DLL和.EXE文件都被创建在“C:\Program Files (x86)\MyApplication”目录下。
但是当我右键点击MSI并选择卸载时,虽然显示了一个无误的卸载菜单,但是"C:\Program Files (x86)\MyApplication"文件夹没有被删除。
如何定义卸载功能以删除此文件夹?
以下是我的Product.wxs一部分内容:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*"
Name="My Application"
Language="1033"
Version="1.0.0.0"
Manufacturer="Me"
UpgradeCode="36944ae1-9e9f-4ef0-a860-9d894e0c28ef">
<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="My Application" Level="1">
<ComponentGroupRef Id="ProductComponents"/>
<ComponentRef Id ="ApplicationShortcut"/>
<ComponentRef Id ="ApplicationShortcutDesk"/>
<ComponentRef Id ="RemoveAll"/>
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="My Application"/>
</Directory>
<Directory Id="DesktopFolder" SourceName="Desktop"/>
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="My Application">
<Directory Id="fr" Name="fr"/>
<Component Id="RemoveAll" Guid="{63F6943C-7707-41CA-BAB9-7438471EC81E}">
<RemoveFile Id="RemoveAllFilesOnUninstall" Directory="INSTALLFOLDER" Name ="*.*" On ="uninstall"/>
<RemoveFolder Id="RemoveAllFoldersOnUninstall" Directory="INSTALLFOLDER" On="uninstall"/>
<RegistryValue Root="HKLM" Key="Software\Microsoft\MyApplication" Name="Path" Type="string" Value="[INSTALLFOLDER]" KeyPath="yes" />
<util:RemoveFolderEx On="uninstall" Property="INSTALLFOLDER" />
</Component>
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="{3B0B5064-807C-4E29-A701-E77BE8B8FA86}">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="My Application"
Target="[#MyApplication.exe]"
WorkingDirectory="INSTALLFOLDER"/>
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\MyApplication" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationShortcutDesk" Guid="{61087C99-9CA8-4191-8251-219DFDAFC666}">
<Shortcut Id="ApplicationStartDeskShortcut"
Name="My Application"
Target="[#MyApplication.exe]"
WorkingDirectory="INSTALLFOLDER"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\MyApplication" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents">
<Component Id="ProductComponent" Guid="{5C62E31A-C787-4B45-A4F7-2324A12C72D1}" Directory="INSTALLFOLDER">
<!-- List of DLL/EXE -->
</ComponentGroup>
</Fragment>
</Wix>
编辑:我现在使用UtilExtension
,INSTALLFOLDER
已经正确删除。唯一需要重命名的是ApplicationShortcutDesk
和ApplicationStartMenuShortcut
。对于快捷方式来说,RemoveFolder
是如何工作的?
msiexec /x msiname.msi /l*v uninstall.log
进行卸载。 - Anton SutarminUtilExtension
(你说得对,自定义操作是个坏主意)。安装文件夹现在已被删除!我只需要删除创建的两个快捷方式。 - A.Pissicat