Search code examples
visual-studio-2010sql-server-2008windows-installerstack-overflow

SQL Server setup.exe within a custom msi causes StackOverflowException


I'm trying to create an .msi installer that also installs SQL Server (if the user has the disk/iso file).

How it should work is:

  • it runs a batch file, and the batch file finds the setup.exe in whichever drive it is.
  • The batch file takes 2 arguments, the location of the configuration file and the install directory of the msi
  • it then searches for setup.exe and runs it with the config file, performing a silent install.

The arguments seem to be exactly the same which ever way I run it.

@echo off
::this file searches for the setup.exe and then installs the server.
::ARGUMENTS:Complete Path to the Configuration File
 ::ATTENTION: this will need to search for a more unique file in the future!
 ::loop through each letter for a drive
 for %%A in (D E F G H I J K L M N O P Q R S T U V W X Y Z) Do ( 
::check if file exists, send any error messages to NUL, destroying it(e.g. no disk      in drive) and installif found
DIR  "%%A:/setup.exe" 1>NUL 2>&1 && call:install %%A %1 %2

::if we reach here the file ahsn't been found
if %%A == Z (
    @echo Please insert the Microsoft SQL Server 2008 R2 disk and try again.
    pause
    exit
)
)
 :install
net user grp-db ..grp.. /add
echo Installing SQL Server 2008 R2 with %~2 
date/t  
time /t
::"%~1:\setup.exe" /ConfigurationFile="%~2"
DIR "%~2"
date/t
time /t
pause
echo Creating ODBC data source.. with %~3
::"%~3"ODBCCONF.exe CONFIGSYSDSN "SQL Server" "DSN=GRP_DSN | Description=GRP Data         Source | SERVER=(local) | Trusted_Connection=Yes"
exit
goto:eof

Running the batch file from Command Prompt works perfectly as expected but in the msi it causes a StackOverflowException. Checking the Summary file in the SQL directory says

The user cancelled the operation. Exception type: Microsoft.SqlServer.Chainer.Infrastructure.CancelException.

Has anybody got ANY ideas where to even start with this one?


Solution

  • It looks like there is a conflict between the SQL Server installation and your MSI process.

    Instead of using a BAT for installing SQL Server, you can try adding it as a prerequisite for your MSI: