Installing SQL Server with application

Feb 9, 2011 at 7:50 PM
Edited Feb 9, 2011 at 8:13 PM


I am learning dotNetInstaller to package my application along with SQL Server 2008. I am not able to find proper examples of how to achieve this.

My problem: Bootstrapper should first check if SQL Server Express is already installed. If not it will display the dialog to install it. I tried a simple example of doing this (config file as below). But its displaying my product's name as one of the components to be installed, which the user can de-select - which i dont want.

<?xml version="1.0" encoding="utf-8"?>
<configurations lcid_type="UserExe" show_language_selector="False" language_selector_title="" language_selector_ok="OK" language_selector_cancel="Cancel" configuration_no_match_message="" ui_level="full" fileversion="" productversion="" log_enabled="False" log_file="#TEMPPATH\dotNetInstallerLog.txt">
  <schema version="1.10.1525.0" generator="dotNetInstaller InstallerEditor" />
  <configuration dialog_caption="MyWebsite Installer" dialog_message="In order to install MyWebsite you must first install these components:" 
 dialog_message_uninstall="" dialog_bitmap="#APPPATH\banner.bmp" skip_caption="Skip" install_caption="Install" supports_install="True" supports_uninstall="True">
 <component package="#CABPATH\SQLEXPRWT_x86_ENU.msi" cmdparameters="/QS /ACTION=Install /IACCEPTSQLSERVERLICENSETERMS /FEATURES=SQL,Tools /ERRORREPORTING=0 /INSTANCENAME=&quot;MyWebsite&quot;"  id="SQLServer2008 x86" display_name="SQL Server 2008 (x86)" type="exe" >
      <installedcheck path="SOFTWARE\Microsoft\Microsoft SQL Server" fieldname="InstalledInstances" fieldvalue="MyWebsite" defaultvalue="False" 
   fieldtype="REG_MULTI_SZ" comparison="exists" rootkey="HKEY_LOCAL_MACHINE" wowoption="NONE" type="check_registry_value" description="Installed Check" />
      <embedfile sourcefilepath="#APPPATH\SQLEXPRWT_x86_ENU.exe" targetfilepath="SQLEXPRWT_x86_ENU.exe" />
    <component package="#APPPATH\MySiteSetup.msi" cmdparameters="" cmdparameters_silent="/qn" cmdparameters_basic="/qb-" uninstall_package="" uninstall_cmdparameters="/qb-" id="MySiteSetup.msi" display_name="MySiteSetup.msi" type="msi" allow_continue_on_error="True" default_continue_on_error="False" required_install="False" required_uninstall="False" selected_install="True" selected_uninstall="True" note="" processor_architecture_filter="" status_installed="" status_notinstalled="" supports_install="True" supports_uninstall="True" show_progress_dialog="True" show_cab_dialog="True">
      <embedfile sourcefilepath="#APPPATH\MySiteSetup.msi" targetfilepath="MySiteSetup.msi" />

Can someone please post a step by step example of how to create bootstrapper with dotNetInstaller, please?

Thanks so much!

Feb 9, 2011 at 8:38 PM

I think you just need to set required_install
Feb 9, 2011 at 8:55 PM
Edited Feb 9, 2011 at 9:21 PM

Thanks Neil. That did  the trick.

However I would like to confirm one thing here: I understood that the very fist screen for the setup created by dotNetInstaller would just display all the components that are required before installing target application.

Here MySiteSetup is my target application. Why this is being display on the main dialog? Should'nt this msi be displayed later when all the required components are installed/checked successfuly? (Please correct me if I have misunderstood)

I am not able to proceed further as its failing with error "Failed to install SQL Server". Command for installing SQL works perfect on command line. Is there some way to see or create log file from DotnetInstaller as debug what's wrong?

This is happning on Windows 7-32bit machine where SQL Server is not installed. When tested on a machine where SQL Server is installed, SQL Server check is not displayed in the list of required components.

More info: I have placed all the files, SQL Express.exe, mysitesetup.msi, Configuration.xml and other dotNetInstaller supporting files in the same location and have used #APPPATH\[filename] for referencing them.

Any suggestions please?

Feb 9, 2011 at 9:40 PM

I feel the same about dni in that I consider that it just installs the pre-reqs and should then launch my msi - what I do is set complete_command="msiexec /i &quot;#APPPATH\Setup.msi&quot; /L*vx &quot;#TEMPPATH\Setup.log&quot;" (the bit after /L*vx is optional but gives me an msi log file if my install fails).

You can set dni to create a log file by setting log_enabled="True" and log_file="#TEMPPATH\DniSetup.log"

My sql check is different to yours, I use:

<installedcheck path="SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" fieldname="InstanceName" fieldvalue="" defaultvalue="False" fieldtype="REG_SZ" comparison="value_exists" rootkey="HKEY_LOCAL_MACHINE" wowoption="WOW64_64" type="check_registry_value" description="Check for SQL Instance" />

Hope this helps.

Feb 9, 2011 at 11:01 PM

Thanks so much Neil! All is working expcept the SQL check!

1) On one of the Windows 7 machine its detecting that SQL Server is not installed and hence displays the required components dialog. But when clicked on install, it tries to extract the SQLServer.exe file and fails with message "Failed to install SQL Server 2008. Continue with other components?" (FYI: there are no other components requried)

2) Same installer gives following error on other Windows 7 machine (I am using VMs as well as actual test machines) : "This installation package could not be opened. Verify that package exists nad that you can access it...."

    In this case, I did try to check th DNI log file, but I was not able to find anything unusual. (may be i am not sure what to look for =) )

3) This same installer is able to detect that SQL Server is installed and installs my application on other WIndows 7 machine.

Any further suggestions pelase? Sincere thanks!

Feb 10, 2011 at 12:38 PM

If you could post the log here I can take a look and see if I spot anything.

Feb 10, 2011 at 2:30 PM
  1. The log file for the SQL installer is what you want to be looking at. If it fails, it probably has a good reason. Fyi, you can change all the messages in the configuration.
  2. Run that installer manually, you're probably running into a problem where windows doesn't "trust" the installer. Again, copying the file and running it manually should probably yield the same error. I doubt it has anything to do wiht DNI.
  3. This just shows that (2) is an environment problem.
Feb 10, 2011 at 5:17 PM
Edited Feb 10, 2011 at 6:21 PM

Thanks Neil and dblock,

I looked at the SQL Server installation log file and found that my machine needed a restart. Its works now.

Is it possible to fetch this error and display it in DNI? (sorry for the silly question..just wanted to make the installer more user friendly)

1) Also I am in a need to create a general installer for both 32-bit and 64-bit machines. Based on machine configuration proper SQL Server exe should be executed.

I thought I can do this by adding another component and install check condition for 64 bit OS. But its showing both the x86 and x64 in required components. Not sure how to set the conditions so that proper exe is choosen based on machine configuration.

2) Once the SQL Server gets installed, my msi is launched, but the mouse cursor is shown as busy for few seconds?? But i am still able to click buttons on my application's msi. Just to be sure I ran my app's msi individually and this is not happening here.

Can you please suggest some solution for these?

Many thanks!

Feb 10, 2011 at 6:12 PM

Restart is handled by setting the returncodes_reboot attribute, I set mine to "3010,-2227047362".

You do need 32 & 64 versions (although SQL 32 bit can be made to install on 64 bit). Just duplicate you component and set processor_architecture_filter="x64" or processor_architecture_filter="x86" (and change the install pack).

Feb 10, 2011 at 6:49 PM
Edited Feb 10, 2011 at 6:50 PM

Thanks so much Neil. It now works perfect :-)!!

I have a question regarding installing IIS which i will post seperately.

Feb 10, 2011 at 9:37 PM
Edited Feb 10, 2011 at 10:40 PM


I did mentioned  returncodes_reboot to "3010,-2227047362"., but still SQL Server installation fails on system that requires reboot.

Also instead on displaying the message for "reboot_required" attribute in this condition, it displays the message set for failed_exec_command_continue. I would like to display proper message saying "Reboot is required etc"

Any suggestions? Thank you.

Feb 11, 2011 at 9:46 AM

What is the return code from the SQL install, it should be in the dni log. Also, it is possible that SQL is complaining because there is a pending reboot and it won't install - check the SQL logs to see if this is that case.

Feb 11, 2011 at 3:24 PM

Thanks for your reply Neil.

Following are lines from SQL install log which does say machine requires a reboot:

Overall summary:
  Final result:                  Passed but reboot required, see logs for details
  Exit code (Decimal):           -2067919934
  Exit facility code:            1214
  Exit error code:               3010
  Exit message:                  A computer restart is required. You must restart this computer before installing SQL Server.
  Start time:                    2011-02-10 15:17:59
  End time:                      2011-02-10 15:18:41
  Requested action:              RunRules

Following lines are from dni log:

2011-02-10 15:18:45 --- Component 'SQLServer2008x64 (SQL Server 2008 (x64)): DIALOG CLOSED
2011-02-10 15:18:45 *** Component 'SQLServer2008x64' (SQL Server 2008 (x64)): ERROR - Error executing 'SQLServer2008x64' (SQL Server 2008 (x64)): 0x84be0bc2
2011-02-10 15:18:45 --- Component 'SQLServer2008x64 (SQL Server 2008 (x64))' FAILED: Error executing 'SQLServer2008x64' (SQL Server 2008 (x64)): 0x84be0bc2
2011-02-10 15:21:00 --- Component 'SQLServer2008x64 (SQL Server 2008 (x64)): FAILED, ABORTING
2011-02-10 15:21:00 *** Failed to install one or more components, reloading components (reload_on_error).

 Even though I did mentioned returncodes_reboot to 3010,-2067919934, why is the installer displaying the message set for "failed_exec_command_continue" and not for "reboot_required"?

Basically how does "returncodes_reboot" helps? I read the documentation but did nto got a clear idea?


Feb 11, 2011 at 3:35 PM

Re-check that your 64-bit configuration does have that value. It should have been caught as a reboot since -2067919934 is effectively 0x84BE0BC2 (yes, we need to support hex numbers).

Feb 11, 2011 at 5:23 PM

Yes 64-bit config does has this value  returncodes_reboot = 3010,-2067919934. Still the messages are not getting displayed properly.

Feb 11, 2011 at 5:54 PM

Can you make sure the value doesn't include any spaces e.g. returncodes_reboot="3010,-2227047362"

Feb 11, 2011 at 6:19 PM
Edited Feb 11, 2011 at 6:21 PM

There are no spaces. Following is the SQL Server 64-bit component from my config file. 

Looks like there are some issues on 64-bit machine for me :-( . Though  SQL Server is installed on this Windows 7-64bit machine still the dni installer is trying to install it again.

I have highlighted the installedcheck below. In registry the value does exist, so it should skip SQL server installation. I did changed fieldValue from 1 to MSSQL10_50.SQLEXPRESS, but still its not able to detect it.

Setting fieldValue to 1 does works on 32bit machine, but neither works on 64bit. Does value for wowoption correct here?

<component executable="#APPPATH\SQLEXPRADV_x64_ENU.exe" executable_silent="" returncodes_reboot="3010,-2067919934" executable_basic="" install_directory="" responsefile_source="" responsefile_target="" responsefile_format="none" uninstall_executable="" uninstall_executable_silent="" uninstall_executable_basic="" uninstall_responsefile_source="" uninstall_responsefile_target="" returncodes_success="" exeparameters="/QS /ACTION=Install /IACCEPTSQLSERVERLICENSETERMS /FEATURES=SQL,Tools /ERRORREPORTING=0 /INSTANCENAME=&quot;SQLEXPRESS&quot; /SECURITYMODE=SQL" exeparameters_basic="" exeparameters_silent="" uninstall_exeparameters="" uninstall_exeparameters_basic="" uninstall_exeparameters_silent="" id="SQLServer2008x64" display_name="SQL Server 2008 (x64)" uninstall_display_name="" os_filter="" os_filter_min="" os_filter_max="" os_filter_lcid="" type="exe" installcompletemessage="" uninstallcompletemessage="" mustreboot="False" reboot_required="" must_reboot_required="False" failed_exec_command_continue="" allow_continue_on_error="True" default_continue_on_error="False" required_install="True" required_uninstall="False" selected_install="True" selected_uninstall="True" note="" processor_architecture_filter="x64" status_installed="" status_notinstalled="" supports_install="True" supports_uninstall="False" show_progress_dialog="True" show_cab_dialog="True">
      <installedcheck path="SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" fieldname="SQLEXPRESS" fieldvalue="MSSQL10_50.SQLEXPRESS" defaultvalue="False" fieldtype="REG_SZ" comparison="match" rootkey="HKEY_LOCAL_MACHINE" wowoption="WOW64_32" type="check_registry_value" description="Check SQL Server 2008 (x64)" />
      <embedfile sourcefilepath="#APPPATH\SQLEXPRADV_x64_ENU.exe" targetfilepath="" />


Feb 11, 2011 at 6:28 PM

I think your comparison is wrong:

<installedcheck path="SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" fieldname="SQLEXPRESS" fieldvalue="" defaultvalue="False" fieldtype="REG_SZ" comparison="value_exists" rootkey="HKEY_LOCAL_MACHINE" wowoption="WOW64_64" type="check_registry_value" description="Check for SQLEXPRESS Instance" />

You should only be checking the value exists as its value is not always the same, also you need to set the WOW64_64 option not WOW64_32 as you need to be looking in the 64 registry values not the 32 bit one (dni is 32 bit only so you have to tell it check 64 bit registry).

I am still not sure why it is not reboot, I have the same code and it works perfectly.

Feb 14, 2011 at 3:59 PM

Thanks Neil. You've been a great help!!

Except for the reboot part rest all is working perfect!

Best regards!

Feb 14, 2011 at 5:24 PM

In a couple of your earlier replies you wrote "returncodes_reboot to 3010,-2067919934"; this is not correct, it should be returncodes_reboot="3010,-2227047362". Hopefully it was just a typo but I thought I'd mention it.

Feb 14, 2011 at 5:47 PM

Oh! I just copied the error code of "3010,-2067919934" from the SQL Server intallation log when it was failing for pending restart. Isn't this correct? Or should I always use returncodes_reboot="3010,-2227047362".

Thank you!

Feb 14, 2011 at 5:57 PM

No you need the code -2227047362 (which is 0x84be0bc2 as shown in the sni log not the SQL log).

Feb 14, 2011 at 10:30 PM

I have been adding this to the unit test code and I think the value should be returncodes_reboot="3010,2227047362" i.e. without the minus sign. My SQL install only seems to return 3010, could you try and see if it works without the minus sign.

Feb 14, 2011 at 11:07 PM

Looks like it did work this time with returncodes_reboot="3010,2227047362".  Giving you more background of how I am testing:
I am using a Windows 7 VM. Before testing dni installer for my product, I just roll back it to a clean state where IIS and SQL Server are not installed.

When returncodes_reboot was set to "3010,-2227047362" or "3010,-2067919934", SQL Server install was always failing on pending restart.  So to make it work I was doing a rollback and a restart before installing my application.

But after your change (returncodes_reboot="3010,2227047362"), I just did a rollback WITHOUT restart and it did work. SQL Server got installed successfully :-)

Thanks for all your great help and time. Appreciated.


Feb 15, 2011 at 7:09 AM

Thanks for the update, I'll retry my install on Windows 7.