Search code examples
wixuninstallationsql-server-2014-express

SQL Express 2014 instance not removed on uninstall


I am trying to set up an installation, with sql express 2014 as a prerequisite. The installation itself works fine, but when uninstalling, the instance is not removed. I can still access it through my sql manager and find it in the registry.

This is my Chain:

<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>

This is my 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>

From what i understand, the Permanent="no", should take care of removing the package on uninstall. I have even included and UninstallCommand, but this does not remove the instance either.

What am I missing here?

Let me know if any other info is required to solve this. - Thx!


Solution

  • Exe packages require a DetectCondition to be able to verify whether or not the package is installed. If you notice in your .net exepackage you have

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

    This tells the installer that this package is installed iff the condition is true. You have to do the same thing in your SQL exe package.

    DetectCondition is

    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.

    You can do this by creating some registry searches which set some variables. Try this registry search

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

    Then in your ExePackage for SQL you can put DetectCondition="MicrosoftSQLInstalled" and that will be true if the registry search found the SQLPath registry entry in the key specified.