4

大家早上好。这是我关于stackoverflow的第一个问题,所以希望这不是被打死的东西,我一直找不到它。

我正在开发一个将要分发收缩包装的应用程序。我们已经获得了使用我们的应用程序分发 SQL Server 2008 Express Edition 的权利,但具体如何做到这一点有点困难。现在我们正在使用一个标准的 Visual Studio 安装项目,我显然希望有一些非常简单的东西,比如一个可配置的合并模块,但显然不存在这样的东西,否则我不会在这里发布;)

我开始走的路是在我们的包中包含自解压 EXE,然后使用自定义安装操作来解压它并将命令行参数传递给 SQL 安装程序以创建我们的命名实例。这就是问题所在。

萃取没问题。我可以从 Windows 运行脚本,它会按原样安装 SQL Server,但我无法从我的自定义操作中运行 SQL 安装程序,因为它表示已经有另一个安装正在进行中。当然,另一个安装是我的应用程序,它不会在 SQL Server 完成之前结束,所以我们基本上处于死锁状态,直到 SQL 最终放弃并出现错误。

我想要的是我的应用程序的 SQL 服务器的命名实例,它随它一起安装并随它一起卸载。由于时间原因,编写我自己的安装程序不是一种选择,我的同事说由于复杂性,InstallShield 不是一种选择(我从未使用过它,所以我会相信他的话)。有人有想法吗?

4

5 回答 5

2

当我们尝试使用收缩包装的应用程序部署 SQL 2008 Express R2 的命名实例时,我们遇到了类似的问题。我们确实通过制作自定义引导程序使其工作。以下是我们 wiki 中描述这一点的条目的副本,希望它们对尝试这样做的其他人有用。

需要注意的重要一点是,在 VS2012/2013 中,我们尚未确定如何使用 InstallShield LE (ISLE) 进行这项工作,因此如果您现在采用此解决方案并计划升级 VS,那么这可能不值得这样做,最好找到一个也适用于 ISLE 的解决方案。

用于安装项目的 SQL 2008 R2 先决条件引导程序

在 VS2010 中开箱即用,无法将 SQL2008 Express R2 设置为安装项目的先决条件。这不可能的原因是 R2 没有“引导程序”,只有 2008 Express。此外,MS 不打算为 R2 添加引导程序,因为 VS 只是为发布该版本 VS 时存在的任何 SQL 版本获取引导程序(R2 是在 VS2010 之后发布的)。

由于 SQL 2008 R2 没有 MS 引导程序,因此您需要按照本文创建自己的引导程序:

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 的自定义命名实例。

成功:我们为我们的应用程序版本的 SQL 创建了一个自定义引导程序,它完全取消了 SQLVersionCh.exe 程序。

我们做了什么:

我们从上面详述的 robindotnet 的自定义 R2 引导程序开始。

然后,我们删除了对 sqlversionchk.exe 的所有引用,并将它们替换为注册表检查以检查当前版本的 sql 是什么。这不像 sqlversionchk 那样彻底,因为它还会检查 SQL 实例是否使用正确的语言以及很多关于当前是否安装了 x 版本的 sql 是否无法更新的条件。但是,就我们的目的而言,这并不重要,因为我们控制着实例(因为它是自定义实例而不是默认 SQLEXPRESS 实例)所以我们将知道它可能是什么版本,因此我们可以检查这些版本.

然后引导程序通过简单地检查以下四个场景来工作,其中只有一个应该是真实的(即四个场景应该是互斥的)

场景 1:平台:x86
注册表检查:我们的实例名称没有注册表值操作:注册表中没有任何内容,因此未安装 SQL,如果这是 x86 机器安装 SQL

场景 2:平台:x86
注册表检查:注册表值不等于我们正在使用的最新 SQL 版本
操作:将我们现有的自定义命名实例升级到我们当前使用的 SQL 版本。

如果安装的 SQL 版本比我们尝试安装的版本高(因为我们将升级到较早的版本,这会失败),这个逻辑在理论上是错误的,但除非用户决定手动安装,否则这种情况永远不会发生升级我们的 SQL 实例,这是我们无法控制的。

场景 3:平台:amd64(注意这并不意味着这是一台 amd 机器,只是它是 64 位 Windows 安装)
注册表检查:我们的实例名称没有注册表值
操作:注册表中没有任何内容,因此没有安装 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>
于 2013-10-22T17:50:13.500 回答
1

这个项目中的代码是为 SQL2005 构建的,但看起来它可以很容易地用于部署 SQL2008。

http://www.codeproject.com/KB/applications/NET_Installer_With_SQLEXP.aspx

它还支持您选择的实例名称。它肯定需要一些调整,但它似乎支持你正在尝试做的基本租户。

于 2009-03-27T21:41:17.280 回答
1

我将继续回答我自己的问题,以便其他任何人来寻找有关 SO 的此类信息......从我所能告诉的一切来看,它只是无法安装SQL Server 的自定义实例(无论如何是 2008 年,可能是 2005 年),它与自定义软件的安装相关联,而无需使用自定义引导程序或第三方安装程序产品(InstallShield 等)。听起来 SQL Server Compact 版本可能更适合。

于 2009-03-29T13:43:21.343 回答
1

不知道还有没有人关注这个。也许你可以看看这个:

http://msdn.microsoft.com/en-us/library/dd981032(SQL.100).aspx

没有尝试过,但我希望解决亚当发布的完全相同的问题。

于 2010-08-25T02:27:02.210 回答
0

一种方法是包含 SQL Server 2008 Express 安装包,然后在 Windows 安装程序中使用自定义操作来启动 SQL Server 2008 Express 的静默后台安装。

该软件包是一个标准的 MSI 软件包 - 在安装 MSI 时,您应该能够在命令行上设置大量属性。

这是我找到的一个示例:

sqlexpr.exe /qb instancename="MACHINENAMESQLEXPRESS2008" 
SQLAUTOSTART=1 SAPWD="PWD" SECURITYMODE=SQL DISABLENETWORKPROTOCOLS=0"

我敢肯定,命令行属性的完整列表应该可以在 Microsoft 或 SQL Server 2008 Express 的帮助文件中找到。

马克

于 2009-03-26T06:31:01.937 回答