ClickOnce Prerequisites: Add SQL Server Express 2016 LocalDB package Manually

You can include the sqlLocalDB.msi with your installer package and then run a silent install as part of your setup. I use the Visual Studio Setup & Deployment project add-in. You can specify prerequisites by selecting the setup project properties. It will list all the bootstrapper packages that it finds in “C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages” (for VS 2015). A bootstrapper consists of two files: the product.xml file and a package.xml file in a subfolder for the locale of interest, e.g. \en\. Source

Here’s my product.xml:

<?xml version="1.0" encoding="utf-8"?>
<Product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" ProductCode="Microsoft.SqlServer.SqlLocalDB.13.0">
  <RelatedProducts>
    <IncludesProduct Code="Microsoft.SqlServer.SqlLocalDB.13.0" />
  </RelatedProducts>

  <PackageFiles CopyAllPackageFiles="false">
   
    <PackageFile
      Name="sqllocaldb.msi"
      HomeSite="sqllocaldb"
      PublicKey="3082010a0282010100932edad8e63e98d91b0f645f4da8584d143bf77a84fc3c11313aef89c24a2d41a5485ddd129eefab662834d57d2a557b4c4d8af2c0f1b2d352158bb6b308b88b500bdd7ffb6a09a0dc6704c4f1dfbc75182040be782c9956ddeef52edd3e42f95a1f30ae01148ab082b551a0e26d65fef7180a8d306d4d3aa7c5f3362dee5f2ca09200b11c4ce2cbf7ff24257fd78fc0dd976eceb217b6c71c44a724ca7e81e6e631b916d95d3ed168eebecd48d0862caedc0e21c1c08ac3ee1b935913f6c63b8072188853fbabbf303ea077bd5288bf7ad8e8b093ada11b8cd47ea6105010bee1c81c64fa872efbc4476616c0847b36af5fba85446c020f2de0b00e1ba23e250203010001"
    />
  </PackageFiles>

  <InstallChecks>
    <!-- Check if already installed -->
    <FileCheck
      Property="sqllocaldbVersion"
      FileName="sqlservr.exe"
      SearchPath="Microsoft SQL Server\130\LocalDB\Binn"
      SpecialFolder="ProgramFilesFolder"
    />
    <!-- Check for x64 install from x86 installer -->
    <FileCheck
      Property="sqllocaldbVersion_x64"
      FileName="sqlservr.exe"
      SearchPath="Program Files\Microsoft SQL Server\130\LocalDB\Binn"
      SpecialFolder="WindowsVolume"
    />
  </InstallChecks>

  <Commands Reboot="Defer">
   <Command PackageFile="sqllocaldb.msi" Arguments="IACCEPTSQLLOCALDBLICENSETERMS=YES" EstimatedInstallSeconds="90">
      <InstallConditions>
        <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="amd64" />
        <BypassIf Property="sqllocaldbVersion" Compare="VersionGreaterThanOrEqualTo" Value="13.0.2151.0" />
        <BypassIf Property="sqllocaldbVersion_x64" Compare="VersionGreaterThanOrEqualTo" Value="13.0.2151.0" />
      </InstallConditions>
      <ExitCodes>
        <ExitCode Value="0" Result="Success" />
        <ExitCode Value="1641" Result="SuccessReboot" />
        <ExitCode Value="3010" Result="SuccessReboot" />
        <DefaultExitCode Result="Fail" String="GeneralFailure" FormatMessageFromSystem="true" />
      </ExitCodes>
    </Command>
  </Commands>
</Product>

Here’s the corresponding package.xml with URLS FIXES

<?xml version="1.0" encoding="utf-8"?>
<Package Name="DisplayName" LicenseAgreement="Eula.rtf" Culture="Culture" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
  <PackageFiles>
    <PackageFile Name="Eula.rtf" />
  </PackageFiles>
  <Strings>
    <String Name="Culture">en</String>
    <String Name="DisplayName">SQL Server 2016 Express LocalDB</String>
    <String Name="sqllocaldb_32">http://download.microsoft.com/download/1/5/6/156992E6-F7C7-4E55-833D-249BD2348138/ENU/x86/SqlLocalDB.msi</String>
    <String Name="sqllocaldb">http://download.microsoft.com/download/1/5/6/156992E6-F7C7-4E55-833D-249BD2348138/ENU/x64/SqlLocalDB.msi</String>
    <String Name="AdminRequired">You do not have the permissions required to install SQL Server 2016 Express LocalDB. Please contact your administrator.</String>
    <String Name="GeneralFailure">An error occurred attempting to install SQL Server 2016 Express LocalDB.</String>
    <String Name="InvalidPlatformOS">The current operating system version does not support SQL Server 2016 Express LocalDB.</String>
    <String Name="InvalidPlatformOSServicePack">The current operating system does not meet Service Pack level requirements for SQL Server 2016 Express LocalDB. Install the most recent Service Pack from the Windows Service Pack and Update Center at http://windows.microsoft.com/en-us/windows/service-packs-download before continuing setup.</String>
  </Strings>
</Package>


Comments

comments

Leave a Reply