之前收到一个任务,制作安装包,要求把必备的一些必备的组件如.NET Framework这些玩意用一键安装的形式安装上去,SQL Server是必备的其中之一。可是在系统必备处勾选了SQL Server 2005 Express SP2(x86),在生成的时候报错了:
系统必备组件的安装位置未设置为“组件供应商的网站”,并且无法在磁盘上找到项“SQL Server 2005 Express Edition SP2 (x86)”中的文件“SqlExpress\sqlexpr32.exe”。有关详细信息,请参见帮助。
可是我谷歌了也谷不出办法。安装了SQL Server 2005 Express也是无补于事,还有另一件头痛的事,安装SQL Server 2005还需要.NET Framework2.0,这样系统必备组件我的VS2010里面压根就没有啊!这个在网上找了一下还是有解决办法。就是到VS2005或VS 2008的C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages里面把 DotNetFX文件夹复制到C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages下面。果然在系统必备里多了一项。
对这个做法思考一番,看了一下各个文件夹下面的文件,又尝试了一下,终于悟出了一些东西,沿用类似的方法,就可以自定义添加系统必备了。
首先要了解一下每个必备项的安装目录结构,拿这个SQL Server2008的作为例子
接着随便进入一种语言的目录下看看,选择了中文汉语的。
上面提及到两个配置文件,要添加好一个“系统必备”无非就是配置好这些必备组件的安装信息罢了。
由于还没完全弄明白各个节点各个属性的含义,只是把弄明白的列出来
product.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <!-- SQL Express 2008 VS Bootstrapper : product.xml : Language neutral information --> 3 <Product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" ProductCode="Microsoft.Sql.Server.Express.10.0"> 4 <RelatedProducts> 5 <EitherProducts> 6 <DependsOnProduct Code=".NETFramework,Version=v4.0" /> 7 <DependsOnProduct Code="Microsoft.Net.Framework.3.5.SP1" /> 8 </EitherProducts> 9 <DependsOnProduct Code="Microsoft.Windows.Installer.4.5" /> 10 <IncludesProduct Code="Microsoft.Sql.Server.Express.1.0" /> 11 <IncludesProduct Code="Microsoft.Sql.Server.Express.9.2" /> 12 </RelatedProducts> 13 <PackageFiles> 14 <PackageFile Name="SqlExpressChk.exe" /> 15 </PackageFiles> 16 </Product>
package.xml
1 <?xml version="1.0" encoding="utf-8" ?> 2 <Package 3 xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" 4 Name="DisplayName" 5 Culture="Culture" 6 LicenseAgreement="eula.rtf"> 7 8 <PackageFiles CopyAllPackageFiles="false"> 9 <PackageFile Name="SQLEXPR32_x86_CHS.EXE" HomeSite="SqlExpr32Exe" PublicKey="3082010a0282010100bd72b489e71c9f85c774b8605c03363d9cfd997a9a294622b0a78753edee463ac75b050b57a8b7ca05ccd34c77477085b3e5cbdf67e7a3fd742793679fd78a034430c6f7c9bac93a1d0856444f17080df9b41968aa241cfb055785e9c54e072137a7ebce2c2fb642cd2105a7d6e6d32857c71b7ace293607cd9e55ccbbf122eba823a40d29c2fbd0c35a3e633dc72c490b7b7985f088ef71bd435ae3a3b30df355fb25e0e220d3e79a5e94a5332d287f571b556a0c3244ef666c6ff0389cef02ad9aa1dd9807100e3c1869e2794e4614e0b98cd0756d9cac009c2d42f551b85af4784583e92e7c2bbb5dcd196128ad94430ac56a42ffb532aea42922de16e8d30203010001"/> 10 <PackageFile Name="SQLEXPR_x64_CHS.EXE" HomeSite="SqlExpr64Exe" PublicKey="3082010a0282010100bd72b489e71c9f85c774b8605c03363d9cfd997a9a294622b0a78753edee463ac75b050b57a8b7ca05ccd34c77477085b3e5cbdf67e7a3fd742793679fd78a034430c6f7c9bac93a1d0856444f17080df9b41968aa241cfb055785e9c54e072137a7ebce2c2fb642cd2105a7d6e6d32857c71b7ace293607cd9e55ccbbf122eba823a40d29c2fbd0c35a3e633dc72c490b7b7985f088ef71bd435ae3a3b30df355fb25e0e220d3e79a5e94a5332d287f571b556a0c3244ef666c6ff0389cef02ad9aa1dd9807100e3c1869e2794e4614e0b98cd0756d9cac009c2d42f551b85af4784583e92e7c2bbb5dcd196128ad94430ac56a42ffb532aea42922de16e8d30203010001"/> 11 <PackageFile Name="eula.rtf"/> 12 </PackageFiles> 13 14 <InstallChecks> 15 <ExternalCheck Property="SQLExpressChk" PackageFile="SqlExpressChk.exe" Arguments="10.0.1600 2052"/> 16 </InstallChecks> 17 18 <Commands Reboot="Defer"> 19 20 <!-- Defines a new installation (x86) --> 21 <Command PackageFile="SQLEXPR32_x86_CHS.EXE" 22 Arguments='/q /hideconsole /action=Install /features=SQL /instancename=SQLEXPRESS /enableranu=1 /sqlsvcaccount="NT Authority\Network Service" /AddCurrentUserAsSqlAdmin /skiprules=RebootRequiredCheck' 23 EstimatedInstalledBytes="225000000" 24 EstimatedInstallSeconds="420"> 25 <InstallConditions> 26 <FailIf Property="VersionNT" Compare="ValueNotExists" String="GeneralFailure"/> 27 <FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.1.2" String="InvalidPlatformXP"/> 28 <FailIf Property="VersionNT" Compare="VersionEqualTo" Value="5.2.0" String="InvalidPlatform2K3"/> 29 <FailIf Property="VersionNT" Compare="VersionEqualTo" Value="5.2.1" String="InvalidPlatform2K3"/> 30 <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/> 31 <FailIf Property="SQLExpressChk" Compare="ValueEqualTo" Value="-1" String="InvalidUpgradeNotExpress"/> 32 <FailIf Property="SQLExpressChk" Compare="ValueEqualTo" Value="-2" String="InvalidUpgradeNotExpressCore"/> 33 <FailIf Property="SQLExpressChk" Compare="ValueEqualTo" Value="-3" String="InvalidUpgradeLanguage"/> 34 <FailIf Property="SQLExpressChk" Compare="ValueEqualTo" Value="-4" String="InvalidUpgradeWoW"/> 35 <FailIf Property="SQLExpressChk" Compare="ValueLessThan" Value="-4" String="GeneralFailure"/> 36 <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel"/> 37 <BypassIf Property="SQLExpressChk" Compare="ValueNotEqualTo" Value="1"/> 38 </InstallConditions> 39 <ExitCodes> 40 <ExitCode Value="0" Result="Success"/> 41 <ExitCode Value="1641" Result="SuccessReboot"/> 42 <ExitCode Value="3010" Result="SuccessReboot"/> 43 <!-- 0x84BE0BC2 (1214,3010) --> 44 <ExitCode Value="-2067919934" Result="FailReboot"/> 45 <!-- 0x84C10BC2 (1217,3010) --> 46 <ExitCode Value="-2067723326" Result="FailReboot"/> 47 <!-- 0x84BE0007 (1214,7) --> 48 <ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/> 49 <!-- 0x84C4001F (1220,31) --> 50 <ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/> 51 <!-- 0x84BE0001 (1214,1)--> 52 <ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/> 53 <!-- 0x84C4000B (1220,11) --> 54 <ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/> 55 <!-- 0x84BE01F8 (1214,504) --> 56 <ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/> 57 <!-- 0x84BE01FA (1214,506) --> 58 <ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/> 59 <!-- 0x84BE0202 (1214,514) --> 60 <ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/> 61 <!-- 0x84BE0203 (1214,515) --> 62 <ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/> 63 <ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/> 64 <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" /> 65 </ExitCodes> 66 </Command> 67 68 <!-- Defines an upgrade installation (x86) --> 69 <Command PackageFile="SQLEXPR32_x86_CHS.EXE" 70 Arguments="/q /hideconsole /action=Upgrade /instancename=SQLEXPRESS /skiprules=RebootRequiredCheck" 71 EstimatedInstalledBytes="225000000" 72 EstimatedInstallSeconds="420"> 73 <InstallConditions> 74 <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel"/> 75 <BypassIf Property="SQLExpressChk" Compare="ValueNotEqualTo" Value="2"/> 76 </InstallConditions> 77 <ExitCodes> 78 <ExitCode Value="0" Result="Success"/> 79 <ExitCode Value="1641" Result="SuccessReboot"/> 80 <ExitCode Value="3010" Result="SuccessReboot"/> 81 <!-- 0x84BE0BC2 (1214,3010) --> 82 <ExitCode Value="-2067919934" Result="FailReboot"/> 83 <!-- 0x84C10BC2 (1217,3010) --> 84 <ExitCode Value="-2067723326" Result="FailReboot"/> 85 <!-- 0x84BE0007 (1214,7) --> 86 <ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/> 87 <!-- 0x84C4001F (1220,31) --> 88 <ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/> 89 <!-- 0x84BE0001 (1214,1)--> 90 <ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/> 91 <!-- 0x84C4000B (1220,11) --> 92 <ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/> 93 <!-- 0x84BE01F8 (1214,504) --> 94 <ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/> 95 <!-- 0x84BE01FA (1214,506) --> 96 <ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/> 97 <!-- 0x84BE0202 (1214,514) --> 98 <ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/> 99 <!-- 0x84BE0203 (1214,515) --> 100 <ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/> 101 <ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/> 102 <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" /> 103 </ExitCodes> 104 </Command> 105 106 <!-- Defines a new installation (amd64) --> 107 <Command PackageFile="SQLEXPR_x64_CHS.EXE" 108 Arguments='/q /hideconsole /action=Install /features=SQL /instancename=SQLEXPRESS /enableranu=1 /sqlsvcaccount="NT Authority\Network Service" /AddCurrentUserAsSqlAdmin /skiprules=RebootRequiredCheck' 109 EstimatedInstalledBytes="225000000" 110 EstimatedInstallSeconds="420"> 111 <InstallConditions> 112 <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="amd64"/> 113 <BypassIf Property="SQLExpressChk" Compare="ValueNotEqualTo" Value="1"/> 114 </InstallConditions> 115 <ExitCodes> 116 <ExitCode Value="0" Result="Success"/> 117 <ExitCode Value="1641" Result="SuccessReboot"/> 118 <ExitCode Value="3010" Result="SuccessReboot"/> 119 <!-- 0x84BE0BC2 (1214,3010) --> 120 <ExitCode Value="-2067919934" Result="FailReboot"/> 121 <!-- 0x84C10BC2 (1217,3010) --> 122 <ExitCode Value="-2067723326" Result="FailReboot"/> 123 <!-- 0x84BE0007 (1214,7) --> 124 <ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/> 125 <!-- 0x84C4001F (1220,31) --> 126 <ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/> 127 <!-- 0x84BE0001 (1214,1)--> 128 <ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/> 129 <!-- 0x84C4000B (1220,11) --> 130 <ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/> 131 <!-- 0x84BE01F8 (1214,504) --> 132 <ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/> 133 <!-- 0x84BE01FA (1214,506) --> 134 <ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/> 135 <!-- 0x84BE0202 (1214,514) --> 136 <ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/> 137 <!-- 0x84BE0203 (1214,515) --> 138 <ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/> 139 <ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/> 140 <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" /> 141 </ExitCodes> 142 </Command> 143 144 <!-- Defines an upgrade installation (amd64) --> 145 <Command PackageFile="SQLEXPR_x64_CHS.EXE" 146 Arguments="/q /hideconsole /action=Upgrade /instancename=SQLEXPRESS /skiprules=RebootRequiredCheck" 147 EstimatedInstalledBytes="225000000" 148 EstimatedInstallSeconds="420"> 149 <InstallConditions> 150 <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="amd64"/> 151 <BypassIf Property="SQLExpressChk" Compare="ValueNotEqualTo" Value="2"/> 152 </InstallConditions> 153 <ExitCodes> 154 <ExitCode Value="0" Result="Success"/> 155 <ExitCode Value="1641" Result="SuccessReboot"/> 156 <ExitCode Value="3010" Result="SuccessReboot"/> 157 <!-- 0x84BE0BC2 (1214,3010) --> 158 <ExitCode Value="-2067919934" Result="FailReboot"/> 159 <!-- 0x84C10BC2 (1217,3010) --> 160 <ExitCode Value="-2067723326" Result="FailReboot"/> 161 <!-- 0x84BE0007 (1214,7) --> 162 <ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/> 163 <!-- 0x84C4001F (1220,31) --> 164 <ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/> 165 <!-- 0x84BE0001 (1214,1)--> 166 <ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/> 167 <!-- 0x84C4000B (1220,11) --> 168 <ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/> 169 <!-- 0x84BE01F8 (1214,504) --> 170 <ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/> 171 <!-- 0x84BE01FA (1214,506) --> 172 <ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/> 173 <!-- 0x84BE0202 (1214,514) --> 174 <ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/> 175 <!-- 0x84BE0203 (1214,515) --> 176 <ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/> 177 <ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/> 178 <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" /> 179 </ExitCodes> 180 </Command> 181 182 </Commands> 183 184 <Strings> 185 <String Name="DisplayName">SQL Server 2008 Express Edition</String> 186 <String Name="Culture">zh-CHS</String> 187 <String Name="SqlExpr32Exe">http://go.microsoft.com/fwlink/?LinkID=153228&clcid=0x804</String> 188 <String Name="SqlExpr64Exe">http://go.microsoft.com/fwlink/?LinkID=153229&clcid=0x804</String> 189 <String Name="AdminRequired">您没有安装 SQL Server 2008 Express Edition 所需的权限。请与您的管理员联系。</String> 190 <String Name="GeneralFailure">试图安装 SQL Server 2008 Express Edition 时发生错误。</String> 191 <String Name="InvalidPlatformXP">要安装 SQL Server 2008 Express Edition,需要 Windows XP Service Pack 2 或更高版本。</String> 192 <String Name="InvalidPlatform2K3">要安装 SQL Server 2008 Express Edition,需要 Windows 2003 Service Pack 2 或更高版本。</String> 193 <String Name="MissingMSXml">SQL Server 2008 Express Edition 需要 MSXML。请确保已正确安装 MSXML。</String> 194 <String Name="InsufficientHardware">当前系统不满足 SQL Server 2008 Express Edition 的最低硬件要求。请与您的应用程序供应商联系。</String> 195 <String Name="InvalidPlatformOSServicePacks">当前操作系统不满足 SQL Server 2008 Express Edition 的 Service Pack 级别要求。在继续安装之前,请从位于 http://www.microsoft.com/downloads/search.aspx?displaylang=zh-cn 的 Microsoft 下载中心安装最新的 Service Pack。</String> 196 <String Name="InvalidPlatformIE">此版本的 SQL Server 2008 Express Edition 需要 Internet Explorer 6.0 版(带SP1)或更高版本。若要继续,请安装或升级到 Internet Explorer 的所需版本,然后再次运行安装程序。</String> 197 <String Name="AnotherInstanceRunning">安装程序的另一个实例已经运行。必须完成正在运行的实例,此安装程序才能继续。</String> 198 <String Name="BetaComponentsFailure">在该计算机上检测到 .NET Framework 2.0 或 SQL Server 的测试版。在继续之前,请卸载 SQL Server 2008 组件、SQL Server 支持文件或 .NET Framework 2.0 的任何早期测试版本。</String> 199 <String Name="InvalidPlatformArchitecture">当前处理器结构不支持此版本的 SQL Server 2008 Express Edition。</String> 200 <String Name="InvalidUpgradeNotExpress">名为“SQLEXPRESS”的 SQL Server 2005 实例不是 SQL Server Express 实例,无法将它升级到 SQL Server 2008 Express Service Pack 1。</String> 201 <String Name="InvalidUpgradeNotExpressCore">名为“SQLEXPRESS”的 SQL Server 2005 Express 实例包含 SQL Server Express 2008 Service Pack 1 中未包括的组件。SQL Server Express 2008 SP1 无法升级此实例。请改用具有高级服务的 SQL Server 2008 Express 版本。</String> 202 <String Name="InvalidUpgradeLanguage">名为“SQLEXPRESS”的 SQL Server 2005 Express 实例的语言与此 SQL Server 2008 Express Service Pack 1 的语言不同。SQL Server 2008 Express Service Pack 1 无法升级此实例。</String> 203 <String Name="InvalidUpgradeWoW">SQL Server 2008 Express Service Pack 1 (x64) 无法升级现有的名为“SQLEXPRESS”的 SQL Server 2005 Express (x64 WoW) 实例。请卸载此 SQL Server 2005 Express 实例,然后重新尝试安装 SQL Server 2008 Express Service Pack 1 (x64)。</String> 204 </Strings> 205 </Package>
下面就举两个例子,来说明整个流程
解决“找不到SqlExpress\sqlexpr32.exe”那个错误的
可以到微软官网下载SQL Server 2005 Express的任何一个SP版,我这里就下了SP3版的,听说64位的版本在32位的系统上安装也行,于是我这里单纯弄个64位的安装包进去就算了。
这样打开系统必备的时候只要勾选了SQL Server 2005 Express Edition SP3 (x64)就不会报错了。
但是要是勾SP2还是会报错的,除非你把一个32位的SP2安装包命名为sqlexpr32.exe塞到C:\Program Files \Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\SqlExpress\zh-Hans目录下就没事.
自定义一个系统必备项
我这里就添加一个Dr.COM-客户端安装程序,首先在C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages下新建一个文件夹“TestDrCom”
新建一个product.xml文件,敲入以下内容
1 <?xml version="1.0" encoding="utf-8"?> 2 <Product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" ProductCode="Dr.COM.3.7"> 3 </Product>
新建一个文件夹“zh-Hans”,在里面放置Dr.COM-客户端的安装程序Dr.COM-Client v3.72.exe。
新建一个无厘头的自述文件“fatezero.txt”,文件内容是在百度百科里fate zero的介绍。
接着到添加package.xml文件(由于对这个文件了解不透彻,我是从数据库那边复制过来的)把Package节点的属性LicenseAgreement改成fatezero.txt;把PackageFile 节点的属性Name 改成Dr.COM-Client v3.72.exe;把所有Command节点的属性PackageFile改成Dr.COM-Client v3.72.exe;把所有Command节点的属性Arguments设成空(就是这样子Arguments="",因为不知道这个安装程序的安装命令);把String节点并且属性Name的值是DisplayName的内容改成Dr.COM-客户端安装程序Ver3.72。保存就行了。
在系统必备项的对话框会多了一项
运行生成后的安装程序setup.exe
可惜编码没弄好,显示的只是乱码
由于没有安装程序的命令,这里没达到一键安装的效果,仍然要手动去填写选择安装的配置信息
整篇文章到此结束,由于有部分内容了解得不够多,还请各位多多指点,谢谢!