需要注意的一个重要问题是,在VS2012/2013中,我们还没有解决如何使用InstallShield LE(ISLE)实现这一点,因此,如果您现在正在采用此解决方案并计划升级VS,那么这可能不值得做,最好找到一个也适用于ISLE的解决方案。
由于SQL 2008 R2没有MS bootstrapper,您需要根据本文创建自己的启动程序:
http://robindotnet.wordpress.com/2011/02/06/how-about-a-bootstrapper-package-for-sqlserver-express-2008-r2/
如果不存在具有该名称的旧实例,则此引导程序将创建SQLEXPRESS实例,或者将具有名称SQLEXPRESS的旧实例更新为SQL Express 2008 R2。
注意:更改SQL实例的名称无法按原样进行,因为xml文件使用的sqlversionchk.exe程序被编程为仅检查名为SQLEXPRESS的实例,并且无法向其传递替代名称。我们已通过创建上述文件的新变体解决了此问题,这些文件不使用sqlversionchk exe,而是使用reg检查来确定是否安装了SQL,如果安装了,则确定安装的版本:
SQL 2008 R2命名实例引导
目标:使用正确的VS安装项目引导程序(即勾选2008 R2是安装项目预要求中的先决条件),然后让安装项目安装或升级SQL Server的自定义命名实例。
我们所做的:
我们从Robinotnet的定制R2引导程序开始,如上所述。
然后,我们删除了对sqlversionchk.exe的所有引用,并将它们替换为对sql当前版本的注册表检查。这并不像sqlversionchk那样彻底,因为这还将检查SQL实例是否使用正确的语言,以及许多关于当前安装了x版本SQL则无法更新的条件。但是,出于我们的目的,这并不重要,因为我们控制着该实例(因为它是一个自定义实例而不是默认的SQLEXPRESS实例),所以我们将知道它可能是什么版本,因此我们可以检查这些版本。
情景1:
平台:x86
操作:注册表中没有任何内容,因此如果这是x86机器,则未安装SQL安装SQL
情景2:
平台:x86
操作:将现有自定义命名实例升级到当前使用的SQL版本。
操作:注册表中没有任何内容,因此未安装SQL,如果这是64位计算机,请安装SQL
情景4:
站台:amd64
注册表检查:注册表值不等于我们正在使用的最新SQL版本操作:将现有自定义命名实例升级到我们正在使用的SQL版本。
完整的引导程序文件在本文的末尾有详细说明。
我们可以在注册表中检查我们喜欢的任何版本号,并确定安装了什么版本。然后,我们可以适当地指导执行。例如,如果您需要先升级到2008 R2,然后才能更新到2010,那么我们可以使用bypassIf构造并简单地在上表中引入更多变体来实现这一点。
请注意,自定义实例名称为“MVXBM”
<?xml version="1.0" encoding="utf-8" ?>
<Package
xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
Name="DisplayName"
Culture="Culture"
LicenseAgreement="eula.rtf">
<PackageFiles CopyAllPackageFiles="false">
<PackageFile Name="SQLEXPR32_x86_ENU.EXE" HomeSite="SqlExpr32Exe"/>
<PackageFile Name="SQLEXPR_x64_ENU.EXE" HomeSite="SqlExpr64Exe"/>
<PackageFile Name="eula.rtf"/>
</PackageFiles>
<InstallChecks>
<RegistryCheck Property="SQLVersion" Key="HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\MVXBM\MSSQLServer\CurrentVersion" Value="CurrentVersion" />
</InstallChecks>
<Commands Reboot="Defer">
<!-- Defines a new installation (x86) -->
<Command PackageFile="SQLEXPR32_x86_ENU.EXE"
Arguments='/q /hideconsole /action=Install /features=SQL /instancename=MVXBM /enableranu=1 /sqlsvcaccount="NT Authority\Network Service" /AddCurrentUserAsSqlAdmin /skiprules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms'
EstimatedInstalledBytes="225000000"
EstimatedInstallSeconds="420">
<InstallConditions>
<FailIf Property="VersionNT" Compare="ValueNotExists" String="GeneralFailure"/>
<FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.1.2" String="InvalidPlatformXP"/>
<FailIf Property="VersionNT" Compare="VersionEqualTo" Value="5.2.0" String="InvalidPlatform2K3"/>
<FailIf Property="VersionNT" Compare="VersionEqualTo" Value="5.2.1" String="InvalidPlatform2K3"/>
<FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
<BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel"/>
<BypassIf Property="SQLVersion" Compare="ValueExists"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="1641" Result="SuccessReboot"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<!-- 0x84BE0BC2 (1214,3010) -->
<ExitCode Value="-2067919934" Result="FailReboot"/>
<!-- 0x84C10BC2 (1217,3010) -->
<ExitCode Value="-2067723326" Result="FailReboot"/>
<!-- 0x84BE0007 (1214,7) -->
<ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/>
<!-- 0x84C4001F (1220,31) -->
<ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/>
<!-- 0x84BE0001 (1214,1)-->
<ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/>
<!-- 0x84C4000B (1220,11) -->
<ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/>
<!-- 0x84BE01F8 (1214,504) -->
<ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/>
<!-- 0x84BE01FA (1214,506) -->
<ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/>
<!-- 0x84BE0202 (1214,514) -->
<ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/>
<!-- 0x84BE0203 (1214,515) -->
<ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/>
<ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
<!-- Defines an upgrade installation (x86) -->
<Command PackageFile="SQLEXPR32_x86_ENU.EXE"
Arguments="/q /hideconsole /action=Upgrade /instancename=MVXBM /skiprules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms"
EstimatedInstalledBytes="225000000"
EstimatedInstallSeconds="420">
<InstallConditions>
<BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel"/>
<BypassIf Property="SQLVersion" Compare="ValueNotExists"/>
<BypassIf Property="SQLVersion" Compare="ValueEqualTo" Value="10.50.1600.1"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="1641" Result="SuccessReboot"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<!-- 0x84BE0BC2 (1214,3010) -->
<ExitCode Value="-2067919934" Result="FailReboot"/>
<!-- 0x84C10BC2 (1217,3010) -->
<ExitCode Value="-2067723326" Result="FailReboot"/>
<!-- 0x84BE0007 (1214,7) -->
<ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/>
<!-- 0x84C4001F (1220,31) -->
<ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/>
<!-- 0x84BE0001 (1214,1)-->
<ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/>
<!-- 0x84C4000B (1220,11) -->
<ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/>
<!-- 0x84BE01F8 (1214,504) -->
<ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/>
<!-- 0x84BE01FA (1214,506) -->
<ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/>
<!-- 0x84BE0202 (1214,514) -->
<ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/>
<!-- 0x84BE0203 (1214,515) -->
<ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/>
<ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
<!-- Defines a new installation (amd64) -->
<Command PackageFile="SQLEXPR_x64_ENU.EXE"
Arguments='/q /hideconsole /action=Install /features=SQL /instancename=MVXBM /enableranu=1 /sqlsvcaccount="NT Authority\Network Service" /AddCurrentUserAsSqlAdmin /skiprules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms'
EstimatedInstalledBytes="225000000"
EstimatedInstallSeconds="420">
<InstallConditions>
<BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="amd64"/>
<BypassIf Property="SQLVersion" Compare="ValueExists"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="1641" Result="SuccessReboot"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<!-- 0x84BE0BC2 (1214,3010) -->
<ExitCode Value="-2067919934" Result="FailReboot"/>
<!-- 0x84C10BC2 (1217,3010) -->
<ExitCode Value="-2067723326" Result="FailReboot"/>
<!-- 0x84BE0007 (1214,7) -->
<ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/>
<!-- 0x84C4001F (1220,31) -->
<ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/>
<!-- 0x84BE0001 (1214,1)-->
<ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/>
<!-- 0x84C4000B (1220,11) -->
<ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/>
<!-- 0x84BE01F8 (1214,504) -->
<ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/>
<!-- 0x84BE01FA (1214,506) -->
<ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/>
<!-- 0x84BE0202 (1214,514) -->
<ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/>
<!-- 0x84BE0203 (1214,515) -->
<ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/>
<ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
<!-- Defines an upgrade installation (amd64) -->
<Command PackageFile="SQLEXPR_x64_ENU.EXE"
Arguments="/q /hideconsole /action=Upgrade /instancename=MVXBM /skiprules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms"
EstimatedInstalledBytes="225000000"
EstimatedInstallSeconds="420">
<InstallConditions>
<BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="amd64"/>
<BypassIf Property="SQLVersion" Compare="ValueNotExists"/>
<BypassIf Property="SQLVersion" Compare="ValueEqualTo" Value="10.50.1600.1"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="1641" Result="SuccessReboot"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<!-- 0x84BE0BC2 (1214,3010) -->
<ExitCode Value="-2067919934" Result="FailReboot"/>
<!-- 0x84C10BC2 (1217,3010) -->
<ExitCode Value="-2067723326" Result="FailReboot"/>
<!-- 0x84BE0007 (1214,7) -->
<ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/>
<!-- 0x84C4001F (1220,31) -->
<ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/>
<!-- 0x84BE0001 (1214,1)-->
<ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/>
<!-- 0x84C4000B (1220,11) -->
<ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/>
<!-- 0x84BE01F8 (1214,504) -->
<ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/>
<!-- 0x84BE01FA (1214,506) -->
<ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/>
<!-- 0x84BE0202 (1214,514) -->
<ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/>
<!-- 0x84BE0203 (1214,515) -->
<ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/>
<ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
</Commands>
<Strings>
<String Name="DisplayName">SQL Server 2008 R2 Express - MVXBM</String>
<String Name="Culture">en</String>
<String Name="SqlExpr32Exe">http://download.microsoft.com/download/5/1/a/51a153f6-6b08-4f94-a7b2-ba1ad482bc75/SQLEXPR32_x86_ENU.exe</String>
<String Name="SqlExpr64Exe">http://download.microsoft.com/download/5/1/a/51a153f6-6b08-4f94-a7b2-ba1ad482bc75/SQLEXPR_x64_ENU.exe</String>
<String Name="AdminRequired">You do not have the permissions required to install SQL Server 2008 R2 Express. Please contact your administrator.</String>
<String Name="GeneralFailure">An error occurred attempting to install SQL Server 2008 R2 Express.</String>
<String Name="InvalidPlatformXP">Windows XP Service Pack 2 or later is required to install SQL Server 2008 R2 Express.</String>
<String Name="InvalidPlatform2K3">Windows 2003 Service Pack 2 or later is required to install SQL Server 2008 R2 Express.</String>
<String Name="MissingMSXml">SQL Server 2008 R2 Express requires MSXML. Please ensure MSXML is installed properly.</String>
<String Name="InsufficientHardware">The current system does not meet the minimum hardware requirements for SQL Server 2008 R2 Express. Contact your application vendor.</String>
<String Name="InvalidPlatformOSServicePacks">The current operating system does not meet Service Pack level requirements for SQL Server 2008 R2 Express. Install the most recent Service Pack from the Microsoft download center at http://www.microsoft.com/downloads before continuing setup.</String>
<String Name="InvalidPlatformIE">This version of SQL Server 2008 R2 Express requires Internet Explorer version 6.0 with SP1 or later. To proceed, install or upgrade to a required version of Internet Explorer and then run setup again.</String>
<String Name="AnotherInstanceRunning">Another instance of setup is already running. The running instance must complete before this setup can proceed.</String>
<String Name="BetaComponentsFailure">A beta version of the .NET Framework 2.0 or SQL Server was detected on the computer. Uninstall any previous beta versions of SQL Server 2008 R2 components, SQL Server Support Files, or .NET Framework 2.0 before continuing.</String>
<String Name="InvalidPlatformArchitecture">This version of SQL Server 2008 R2 Express is not supported for the current processor architecture.</String>
<String Name="InvalidUpgradeNotExpress">The instance of SQL Server 2005 named 'SQLEXPRESS' is a not an instance of SQL Server Express. It cannot be upgraded to SQL Server 2008 R2 Express.</String>
<String Name="InvalidUpgradeNotExpressCore">The instance of SQL Server 2005 Express named 'SQLEXPRESS' contains components that are not included in SQL Server 2008 R2 Express. SQL Server 2008 R2 Express SP1 cannot upgrade this instance. Please use SQL Server 2008 R2 Express with Advanced Services instead.</String>
<String Name="InvalidUpgradeLanguage">The instance of SQL Server 2005 Express named 'SQLEXPRESS' is a different language version than this SQL Server 2008 R2 Express. SQL Server 2008 R2 Express cannot upgrade this instance.</String>
<String Name="InvalidUpgradeWoW">SQL Server 2008 R2 Express (x64) cannot upgrade the existing instance of SQL Server 2005 Express (x64 WoW) named 'SQLEXPRESS'. Uninstall this instance of SQL Server 2005 Express and retry installing SQL Server 2008 R2 Express (x64).</String>
</Strings>
</Package>