SQL 卸载时未删除 Express 2014 实例

SQL Express 2014 instance not removed on uninstall

我正在尝试设置安装,前提条件是 sql express 2014。安装本身工作正常,但卸载时,实例不会被删除。我仍然可以通过我的 sql 管理器访问它并在注册表中找到它。

这是我的链条:

<Chain>
        <ExePackage 
            Id="Netfx4Full" 
            Name="dotNetFx40_Full_x86_x64.exe"
            Cache="no" 
            Compressed="no" 
            PerMachine="yes" 
            Permanent="yes" 
            Vital="yes"
            SourceFile="packages\dotNetFx40_Full_x86_x64.exe"
            DownloadUrl="https://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe"
            DetectCondition="Net4FullVersion AND (NOT VersionNT64 OR Net4x64FullVersion)"
            InstallCondition="(VersionNT &lt; v6.0 OR VersionNT64 &lt; v6.0) AND (NOT (Net4FullVersion OR Net4x64FullVersion))">
        </ExePackage>

        <PackageGroupRef Id="Sql2014Express"/>

        <RollbackBoundary />

        <MsiPackage Id="MainPackage" SourceFile="MyApplication.msi" DisplayInternalUI="yes" Compressed="yes" Vital="yes" />
    </Chain>

这是我的 ExePackage:

<PackageGroup Id="Sql2014Express">
    <ExePackage Id="SQL2014Expressx64"
                InstallCondition="VersionNT64 AND NOT SQL2014x64InstanceInstalled"
                SourceFile="packages\SQLEXPR_x64_ENU.exe"
                DownloadUrl="$(var.SqlWebLink64)"
                DisplayName="Installing Microsoft SQL Express 2014"
                InstallCommand="/ACTION=Install /INSTANCENAME=$(var.InstanceName) /FEATURES=SQLENGINE /Q /HIDECONSOLE /SkipRules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms /SQLSVCSTARTUPTYPE=Automatic /SQLSVCACCOUNT=&quot;NT AUTHORITY\NETWORK SERVICE&quot; /AGTSVCACCOUNT=&quot;NT AUTHORITY\NETWORK SERVICE&quot; /ASSYSADMINACCOUNTS=BUILTIN\Administrators /SQLSYSADMINACCOUNTS=BUILTIN\Administrators /BROWSERSVCSTARTUPTYPE=Disabled /ADDCURRENTUSERASSQLADMIN=true /TCPENABLED=1"
                UninstallCommand="/Action=Uninstall /INSTANCENAME=$(var.InstanceName) /FEATURES=SQLENGINE /Q /HIDECONSOLE"
                Cache="yes"
                    Vital="yes"
                Compressed="no"
                PerMachine="yes"
                Permanent="no"/>
...
        </PackageGroup>

据我了解,Permanent="no" 应该负责在卸载时删除软件包。我什至包含了 UninstallCommand,但这也不会删除实例。

我在这里错过了什么?

如果需要任何其他信息来解决此问题,请告诉我。 - 谢谢!

Exe 包需要 DetectCondition 才能验证包是否已安装。如果您在 .net exepackage 中注意到您有

DetectCondition="Net4FullVersion AND (NOT VersionNT64 OR Net4x64FullVersion)"

如果条件为真,这会告诉安装程序安装此包。你必须在你的 SQL exe 包中做同样的事情。

DetectCondition

A condition that determines if the package is present on the target system. This condition can use built-in variables and variables returned by searches. This condition is necessary because Windows doesn't provide a method to detect the presence of an ExePackage. Burn uses this condition to determine how to treat this package during a bundle action; for example, if this condition is false or omitted and the bundle is being installed, Burn will install this package.

您可以通过创建一些设置一些变量的注册表搜索来做到这一点。试试这个注册表搜索

<util:RegistrySearch
        Id='MicrosoftSQLInstalledCheck'
        Root='HKLM'
        Key='SOFTWARE\Microsoft\Microsoft SQL Server$(var.InstanceName)\Setup'
        Win64='yes'
        Value='SQLPath'
        Result='exists'
        Variable='MicrosoftSQLInstalled'/>

然后在 SQL 的 ExePackage 中,您可以放入 DetectCondition="MicrosoftSQLInstalled",如果注册表搜索在指定的键中找到 SQLPath 注册表项,则为真。