SQL Server named instance with Visual Studio 2017 Installer project

Summary: In essence, the below states: 1) Disable the custom action to run the SQL Server setup.exe in your current
MSI. 2) Create a basic WiX Burn Bundle to kick off the SQL
Server setup.exe first, and then kick off your Visual Studio
Installer Project-generated MSI afterwards. Or better yet, make
the whole MSI in WiX as well. Commercial tools such as Advanced Installer and Installshield are viable options – they feature support for this that is built-in (features vary depending on version of prerequisite).

Burn Bundle-Mockup (inspiration, more inspiration):

Just to try to show how the WiX Burn markup works:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

  <Bundle Name="MyCoolTestApp" Version="1.0.0.0" 
          Manufacturer="Someone" UpgradeCode="PUT-GUID-HERE">

    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />

    <util:FileSearch Path="[WindowsFolder]System32\ucrtbase.dll" Variable="VCDISTINSTALLED"/>

    <Chain>

      <ExePackage SourceFile="vc_redist.x64.exe"
                  DetectCondition="VCDISTINSTALLED"
                  InstallCommand="/q /ACTION=Install"
                  RepairCommand="/q ACTION=Repair /hideconsole" />

      <MsiPackage SourceFile="ShortcutDesktop.msi" />

    </Chain>
  </Bundle>
</Wix>

Technical Cause: I am no expert on Visual Studio Installer Projects – it has to be said – every time. However, these projects have a number of limitations and quirks, as you have discovered. One of the quirks is that all custom actions run in deferred mode and in system context (running as LocalSystem) with no impersonation of the launching user. This is likely the cause of the problem seen – as you state yourself.

Though it is possible to post-process the MSI you get from the VS Installer Projects, it is better to eliminate the use of a custom action to kick off the SQL Server install. More details below. The post processing would involve changing custom action type from 3078 to 1030 so user impersonation is enabled – which also means the custom action does not run elevated by the way – and hence can only succeed if the whole MSI was launched elevated.


Note: Below I suggest to use WiX’s Burn feature (Open Source), or an equivalent, capable commercial tool. WiX’s Burn feature can be used with MSI files created by Visual Studio 2017 Installer project, or MSI files created by any other tool for that matter (also EXE files). You just plug the VS2017-generated MSI into the WiX Bundle (or the EXE file). WiX can obviously also create MSI files itself (that is what the framework is for). WiX quick start links.


MSI Technology Quirk: Kicking off other installers from MSI custom actions is not good practice. If the other installer is another MSI (and not just a non-MSI setup.exe), then it is not even possible to do so reliably due to technical limitations (no two MSI InstallExecuteSequences can run at the same time because of a mutex that is set during installation). In other words: concurrent MSI installations are forbidden and technically impossible.

Burn: Enter WiX’s Burn feature – the downloader / bootstrapper / sequencer tool which runs package installations in sequence from its own wrapper setup.exe. It can install MSI files, EXE files, and other kinds of packages – one after the other without technical limitations like that of MSI’s mutex. Serial, not parallel running.

SQL Server Install: You can kick of the SQL Server EXE installer via such a Burn bundle, and you can specify the parameters you list as command line parameters, instead of doing so in managed code (with the runtime requirements that entails). Then you kick off your main MSI afterwards from the same bundle.

Burn Crash Course: There is a learning curve for Burn. It is “fiddly” (it is code / markup – always fiddly), but it is very flexible. I want to add that Advanced Installer seems to have good support for SQL Server deployment, even if have never had the time to investigate properly in detail. Installshield can install EXE files and MSI files in sequence using its Suite projects feature (check the linked screen shot). Not sure of the overall SQL Server support.

Some Burn Sample Links:


Some Links:

Browse More Popular Posts

Leave a Comment