gpt4 book ai didi

sql-server - 在我的应用程序中包括SQL Server 2008 Express的命名实例

转载 作者:行者123 更新时间:2023-12-03 02:50:57 26 4
gpt4 key购买 nike

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

我正在开发一个将被收缩包装的应用程序。我们已经拥有在我们的应用程序中分发SQL Server 2008 Express Edition的权利,但是确切地做到这一点却有些困难。现在,我们正在使用一个标准的Visual Studio安装项目,我显然希望很简单的东西,例如可配置的合并模块,但是显然不存在这样的东西,否则我不会在这里发布;)

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

提取很好。我可以从Windows运行该脚本,它可以按原样安装SQL Server,但是我无法通过自定义操作运行SQL安装程序,因为这表明已经在进行另一次安装。当然,这另一种安装是我的应用程序,直到SQL Server完成才结束。因此,在SQL最终放弃并解决错误之前,我们基本上处于僵局。

我想要的是为我的应用程序安装的SQL Server的命名实例,并随其卸载。由于时间原因,编写自己的安装程序不是一个选择,而我的同事说,由于复杂性,InstallShield不是一个选择(我从未使用过它,所以我会信守诺言)。有人有想法吗?

最佳答案

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

需要注意的重要一点是,在VS2012 / 2013中,我们尚未弄清楚如何与InstallShield LE(ISLE)一起使用,因此,如果您现在采用此解决方案并计划升级VS,那么可能不值得这样做,最好找到在ISLE中也可以使用的解决方案。

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

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

由于没有适用于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实例是否使用正确的语言之类的信息,以及很多有关是否当前安装了SQL x版本的情况,因此无法对其进行更新。但是,出于我们的目的,这无关紧要,因为我们可以控制实例(因为它是自定义实例,而不是默认的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>

关于sql-server - 在我的应用程序中包括SQL Server 2008 Express的命名实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/682047/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com