【问题标题】:Update a single feature in WIX 3.11 installer while leaving the other ones unchanged更新 WIX 3.11 安装程序中的单个功能,同时保持其他功能不变
【发布时间】:2020-05-09 09:22:27
【问题描述】:

我一直在寻找解决方案,但在任何地方都没有运气,所以我在这里问。

我有一个 WIX 3.11 MSI 安装程序来安装我的应用程序。我的应用程序具有多种功能 - 应用程序 (.NET Core WPF)、数据库 (PostgreSQL 12)、文档 (PDF)。当有更新时,99% 的时间只是在应用程序中更新。但是,如果用户在每次更新时都重新安装所有功能,那么自数据库以来的松散数据将被删除并重新创建。

有没有办法只影响次要/主要升级的选定功能,还是我完全搞错了这个升级?

这是我的 Product.wxs 的样子(我已删除变量并替换了 GUID):

<?xml version="1.0" encoding="UTF-8"?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="$(var.ProductCode)" Name="$(var.AppDisplayName) $(var.bitness)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)" Version="$(var.Version)" Language="1033">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Manufacturer="$(var.Manufacturer)" />

    <UIRef Id="WixUI_FeatureTree" />
    <UIRef Id="WixUI_ErrorProgressText" />

    <Condition Message="!(loc.YouNeedToBeAdmin)">
      Privileged
    </Condition>

    <Media Id="1" Cabinet="$(var.CabName)" EmbedCab="yes" />

    <MajorUpgrade DowngradeErrorMessage="!(loc.NewerVersionAlreadyInstalled)" 
                  AllowSameVersionUpgrades="yes"/>

    <Feature Id="Complete" Title="!(loc.FeatureComplete)" Level="1" Description="!(loc.FeatureComplete)" Display="expand" ConfigurableDirectory="INSTALLFOLDER" AllowAdvertise="no" InstallDefault="local" TypicalDefault="install" Absent="disallow">
      <!--MAIN APP FEATURE-->
      <Feature Id="MainApplication" Title="!(loc.FeatureMainApplication)" Level="1" Description="!(loc.FeatureMainApplication)" TypicalDefault="install"  AllowAdvertise="no" InstallDefault="local" Absent="disallow">
        <ComponentRef Id="ApplicationShortcut" />
        <ComponentRef Id="ApplicationShortcutDesktop" />
        <ComponentGroupRef Id="MainApplicationComponents" />
      </Feature>

      <!--DATABASE FILES FEATURE-->
      <Feature Id="Database" Title="!(loc.FeatureDatabase)" Level="1" Description="!(loc.FeatureDatabase)" TypicalDefault="install"  AllowAdvertise="no" InstallDefault="local" Absent="allow">
        <ComponentGroupRef Id="PostgreModule" />
      </Feature>

      <!--DOCUMENTATION FEATURE-->
      <Feature Id="Documentation" Title="!(loc.FeatureDocumentation)" Level="1" Description="!(loc.FeatureDocumentation)" TypicalDefault="install"  AllowAdvertise="no" InstallDefault="local" Absent="allow">
        <ComponentGroupRef Id="Documentation" />
      </Feature>

    </Feature>

    <!--PostgreSQL Custom Actions calling bat files-->
    <CustomAction Id="PostgreSQLCreator"
      FileKey="createPostgreSQL.bat" Execute="deferred" Return="check" Impersonate="no"/>

    <CustomAction Id="PostgreSQLDestroyer"
      FileKey="deletePostgreSQL.bat" Execute="deferred" Return="check" Impersonate="no"/>

    <InstallExecuteSequence>
      <Custom Action="PostgreSQLCreator" After="InstallFiles">
        <![CDATA[(&Database=3) AND NOT(!Database=3)]]>
      </Custom>
      <Custom Action="PostgreSQLDestroyer" Before="RemoveFiles">
        <![CDATA[(&Database=2) AND (!Database=3)]]>
      </Custom>
    </InstallExecuteSequence>

    </Product>

  <!--CREATING DIRECTORIES-->
  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="PlatformProgramFilesFolder">
        <Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
          <Directory Id="INSTALLFOLDER" Name="$(var.AppFolderName)">
          </Directory>
        </Directory>
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="$(var.AppDisplayName)"/>
      </Directory>
      <Directory Id="DesktopFolder" Name="Desktop"/>
      <Directory Id="CommonAppDataFolder">
        <Directory Id="ApplicationProgramDataFolder" Name="$(var.AppFolderName)">
          <Directory Id="ApplicationDatabaseFolder" Name="PostgreSQL" />
        </Directory>
      </Directory>
    </Directory>
  </Fragment>

  <!--MAIN APP EXE-->
  <Fragment>
    <ComponentGroup Id="MainApplicationComponents" Directory="INSTALLFOLDER">
      <Component Id="AdremWpf" Guid="SOME-GUID-HERE" >
        <File Source="$(var.AppSingleExePath)" />
      </Component>
    </ComponentGroup>
  </Fragment>

  <!--MANUAL PDF-->
  <Fragment>
    <ComponentGroup Id="Documentation" Directory="INSTALLFOLDER">
      <Component Id="ReferenceManual" Guid="SOME-GUID-HERE">
        <File Id='Manual' Name='Manual.pdf' Source='Manual.pdf' KeyPath='yes'>
          <Shortcut Id='StartmenuManual' Directory='DesktopFolder' Name='My Manual' Advertise='yes' />
        </File>
      </Component>
    </ComponentGroup>
  </Fragment>

  <!--SHORTCUTS-->
  <Fragment>
    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="SOME-GUID-HERE">
        <Shortcut Id="ApplicationStartMenuShortcut" Name="$(var.AppDisplayName)" Description="!(loc.AppDescription)" Target="[INSTALLFOLDER]$(var.AppSingleExeName)" WorkingDirectory="INSTALLFOLDER" />
        <RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\$(var.AppFolderName)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>
    <DirectoryRef Id="DesktopFolder">
      <Component Id="ApplicationShortcutDesktop" Guid="SOME-GUID-HERE">
        <Shortcut Id="ApplicationDesktopShortcut" Name="$(var.AppDisplayName)" Description="!(loc.AppDescription)" Target="[INSTALLFOLDER]$(var.AppSingleExeName)" WorkingDirectory="INSTALLFOLDER" />
        <RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\$(var.AppFolderName)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>
  </Fragment>

</Wix>

【问题讨论】:

    标签: wix


    【解决方案1】:

    我可能已经想出了一个方法来做到这一点。 WIX 有一个名为 Boostrapper 项目的东西,它能够采用多个安装项目(msi 或 exe 文件)并将它们全部安装在一个安装程序中。在玩了一点之后,我注意到如果您部署一个新版本的 boostrapper 安装程序,其中包含一些新版本的子安装程序和一些相同版本的子安装程序,只有新版本会被重新安装。

    例子:

    假设您有两个具有以下子安装程序版本的引导程序安装程序:

    Boostrapper 安装程序 1.0.0.0

    • WPF 应用安装程序 1.0.0.0
    • 数据库安装程序 1.0.0.0

    Boostrapper 安装程序 1.0.1.0

    • WPF 应用安装程序 1.0.1.0
    • 数据库安装程序 1.0.0.0

    如果您安装引导程序安装程序 1.0.0.0,然后安装引导程序安装程序 1.0.1.0,则只会重新安装 WPF 应用程序,而不会影响数据库。

    【讨论】:

      猜你喜欢
      • 2017-10-01
      • 1970-01-01
      • 2010-12-17
      • 1970-01-01
      • 2011-01-13
      • 2023-02-09
      • 2012-05-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多