我有一个 WiX 3 安装项目,使用带有 Wix 工具集 v3.11 的 VS 2017 社区,使用以下命令安装输出:
msiexec /i cient.setup.msi /lv output.log
一切都是好的。卸载使用
msiexec /x cient.setup.msi /lv output.log
也很好。但是,如果我重建 WiS 安装项目,然后尝试使用上述命令卸载,我会从 MSI 输出中收到错误 1602。即“此操作仅对当前安装的项目有效”
这是我的Product.wxs
文件的内容:
<?xml version="1.0" encoding="UTF-8"?>
<!-- The name of the product -->
<?define Name = "Notification Client" ?>
<!-- The manufacturer, for setup package publisher and folder info -->
<?define Manufacturer = "MyCompanies IT" ?>
<!-- The version number of this setup package-->
<?define Version = "1.0.1" ?>
<!-- UpgradeCode must be unique and not changed once the first version of the program is installed. -->
<?define UpgradeCode = "{GUID-HERE}" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<?define ClientService_TargetDir=$(var.ClientService.TargetDir)?>
<Product Id="*" Name="$(var.Name)" Manufacturer="$(var.Manufacturer)" Language="1033" Version="$(var.Version)" UpgradeCode="$(var.UpgradeCode)">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Feature Id="ProductFeature" Title="Client.Setup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="ApplicationShortcut" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
<Directory Id="INSTALLFOLDER" Name="$(var.Name)" />
<Component Feature="ProductFeature" Id="SetFolderPermissions" Guid="*">
<CreateFolder>
<util:PermissionEx User="Users" GenericAll="yes" />
</CreateFolder>
</Component>
</Directory>
</Directory>
<Directory Id="StartupFolder" SourceName="Startup"/>
</Directory>
</Fragment>
<Fragment>
<DirectoryRef Id="StartupFolder">
<Component Id="ApplicationShortcut" Guid="*">
<Shortcut Id="StartupShortcut"
Directory="StartupFolder"
Name="Notification Client"
Target="[INSTALLFOLDER]\NotificationClient.exe"
WorkingDirectory="INSTALLFOLDER"
/>
<RemoveFolder Id="CleanUpShortCut" Directory="StartupFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\NotificationClient" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
<Component Id="NotificationClient.exe" Guid="*">
<File Id="NotificationClient.exe" Name="NotificationClient.exe" Source="$(var.ClientService_TargetDir)NotificationClient.exe" DiskId="1" KeyPath="yes" />
</Component>
<Component Id="NotificationClient.exe.config" Guid="*">
<File Id="NotificationClient.exe.config" Name="NotificationClient.exe.config" Source="$(var.ClientService_TargetDir)NotificationClient.exe.config" KeyPath="no" />
</Component>
<Component Id="Newtonsoft.Json.dll" Guid="*">
<File Id="Newtonsoft.Json.dll" Name="Newtonsoft.Json.dll" Source="$(var.ClientService_TargetDir)Newtonsoft.Json.dll" KeyPath="no" />
</Component>
<Component Id="Notifications.dll" Guid="*">
<File Id="Notifications.dll" Name="Notifications.dll" Source="$(var.ClientService_TargetDir)Notifications.dll" KeyPath="no" />
</Component>
<Component Id="OHR_StdFunctions.dll" Guid="*">
<File Id="OHR_StdFunctions.dll" Name="OHR_StdFunctions.dll" Source="$(var.ClientService_TargetDir)OHR_StdFunctions.dll" KeyPath="no" />
</Component>
<Component Id="OHR_MSGraph.dll" Guid="*">
<File Id="OHR_MSGraph.dll" Name="OHR_MSGraph.dll" Source="$(var.ClientService_TargetDir)OHR_MSGraph.dll" KeyPath="no" />
</Component>
<Component Id="ServiceInstallation" Guid="*">
<!-- Remove all files from the INSTALLFOLDER on uninstall -->
<RemoveFile Id="ALLFILES" Name="*.*" On="both" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
我感觉这与 GUID 问题有关,但我遵循了其他帖子中关于大写 GUID 和每次都重新生成产品 ID 的指南,以确保可以顺利推出升级。
我是 Wix 的新手(这是我的第一个项目),因此请善待!:)