【发布时间】: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