首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wix3.11“此操作仅对当前已安装的项目有效”,在重新构建该项目之后

Wix3.11“此操作仅对当前已安装的项目有效”,在重新构建该项目之后
EN

Stack Overflow用户
提问于 2018-01-15 12:09:45
回答 2查看 570关注 0票数 1

我有一个WiX 3安装项目,使用VS 2017社区和Wix v3.11,使用以下方式安装输出:

msiexec /i cient.setup.msi /lv output.log

一切都很好。卸载使用

msiexec /x cient.setup.msi /lv output.log

也没问题。但是--如果我重新构建WiS安装项目,然后尝试使用上面的命令卸载,我将从MSI输出中得到错误1602。,即“此操作仅对当前已安装的项目有效”。

下面是我的Product.wxs文件的内容:

代码语言:javascript
复制
<?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的新手(这是我的第一个项目),所以请善待我!:

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-01-15 13:19:51

您已经将Product设置为自动生成(这很好)。这意味着你编译的每一个MSI都会有一个新的产品GUID --当然。您可以通过指定的MSI文件或指定要卸载的产品GUID来调用MSI卸载。有关这方面的信息,请参阅这个“参考”,您的部分将是第3节在不使用msiexec的情况下从命令行卸载MSI文件 (这个答案有点长,请只关注第3节)。

您是在命令中指定要卸载的MSI文件,它不是当前安装在框上的MSI,因此嵌入在MSI中的产品代码对于当前的卸载(所安装的是以前的版本之一)来说是错误的,使用不同的产品GUID。

您可以定位用于在该框上安装的原始MSI (如果仍然有),然后您的命令msiexec /x cient.setup.msi /lv output.log将工作,或者您可以找出所安装的产品的产品代码是什么,然后卸载如下:msiexec /x {PRODUCT-GUID} /lv output.log。一旦您找到正确的产品GUID,这将始终有效。此卸载从%SystemRoot%\Installer (超级隐藏文件夹)中原始MSI的缓存副本中运行。

下面是查找已安装产品的GUID的一种方法:如何找到已安装的MSI安装程序的产品GUID? (这个答案也有点长,只需查找PowerShell命令就可以了)。

升级:如果您没有为每个设置创建一个新的产品GUID,那么您就不能使用主要的升级。你得到的是一个小的升级。这必须以不同于主要升级的方式安装。大多数人使用主要的升级,因为他们更灵活。您需要实现一个主要的升级,以使您的最新安装程序在安装时悄悄地卸载现有的安装程序,否则会在添加/删除程序中获得两个条目。

设置一个主要的升级:如何:在安装程序中实现主要升级

我会添加你自己建议的链接:如何实现WiX安装程序升级?

票数 1
EN

Stack Overflow用户

发布于 2018-01-15 13:13:15

升级代码用于枚举要删除的潜在候选项,以代替挂起的安装。当您重新构建时,将重新生成/Wix/Product[@Id],因此这将显示为一个新产品,它只需使用您维护的现有升级代码“升级”任何内容。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48262748

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档