如何使用Wix升级必备软件Ms SQL Server

时间:2013-05-16 07:07:58

标签: wix wix3.6

我的应用程序需要MS SQL Server作为其先决条件之一。如果他们有MS SQL Server 2005快速版,我想将客户端计算机升级到MS SQL Server 2008 R2快速版。我无法实现它。下面是我在客户端计算机上没有安装SQL服务器时用于下载和安装MS SQL Server 2008 R2 express版的Wix代码。

 <?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
  xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Fragment>
<util:RegistrySearch Root="HKLM"
                     Key="SOFTWARE\Microsoft\Microsoft SQL Server\MyInstanceName"
                     Variable="Instance"
                     Result="exists"
                     />
     <PackageGroup Id="SqlServer2008R2">
     <ExePackage  InstallCommand='/q /action=INSTALL /HIDECONSOLE   /IACCEPTSQLSERVERLICENSETERMS=1 /FEATURES=SQLEngine /INSTANCENAME=MyInstanceName /SQLSVCACCOUNT="NT AUTHORITY\SYSTEM" /SECURITYMODE=SQL /SAPWD=abc#Wd1234 /ADDCURRENTUSERASSQLADMIN=TRUE /SQLSYSADMINACCOUNTS="NT AUTHORITY\SYSTEM" /TCPENABLED=1 /NPENABLED=1'
              InstallCondition="NOT VersionNT64"
              DetectCondition="Instance"
              Compressed="no"
              Vital="yes"
              PerMachine="yes"
              Name="SQLEXPR32_x86_ENU.exe" 
              Permanent="yes"
              Cache="no"
              DownloadUrl="http://download.microsoft.com/download/5/1/A/51A153F6-6B08-         4F94-A7B2-BA1AD482BC75/SQLEXPR32_x86_ENU.exe"
             >
    <RemotePayload
      Size="60995936"
      ProductName="Microsoft SQL Server 2008 R2 Express"
      Description="Microsoft SQL Server 2008 R2 Express"
      Version="10.50.1600.1"
      CertificatePublicKey="672605E36DD71EC6B8325B91C5FE6971390CB6B6"
      CertificateThumbprint="9617094A1CFB59AE7C1F7DFDB6739E4E7C40508F"
      Hash="ACF5494D18EDF117A2683D66A96FB8954F98D86D"
      />
    </ExePackage>
   </PackageGroup>
   </Fragment>
 </Wix>

1 个答案:

答案 0 :(得分:1)

您无法使用/action=INSTALL参数升级仅安装新实例的实例。您必须使用/action=UPGRADE创建另一个ExePackage并设置InstallCondition以根据您执行的注册表搜索选择正确的ExePackage:

   <ExePackage Id="SqlExpress2008R2_UpgradeNamedInstance"
               Cache="no"
               Compressed="no"
               PerMachine="yes"
               Permanent="no"
               Vital="yes"
               InstallCommand="/QS /ACTION=Upgrade /IACCEPTSQLSERVERLICENSETERMS /BROWSERSVCSTARTUPTYPE=Automatic /INSTANCENAME=&quot;[SqlInstance]&quot;"
               Name="redist\SQLEXPR_x86_ENU.exe"
               DownloadUrl="http://download.microsoft.com/download/D/1/8/D1869DEC-2638-4854-81B7-0F37455F35EA/SQLEXPR_x86_ENU.exe"
               InstallCondition="SqlInstance AND SqlServerInstalled AND NOT SQLServer2008R2Installed">
    <RemotePayload ProductName="SQL Server 2008 R2 Express SP1"
                   Description="SQL Server 2008 R2 Express SP1"
                   CertificatePublicKey="5C499B10F7EF186DC729991A262AB52066423909"
                   CertificateThumbprint="93859EBF98AFDEB488CCFA263899640E81BC49F1"
                   Hash="6F399D641F322A3E47E3DD605F2A2EDF21074375"
                   Size="111274848"
                   Version="10.50.2500.0" />
  </ExePackage>