从 WiX 引导 SQL Express?

我正在开发 WPF 应用程序,并使用 WiX 作为安装程序.

I'm working on a WPF app, and using WiX as an installer.

我想开始使用 SQL Express 2012,但想先解决安装程序问题.

I'd like to start using SQL Express 2012, but want to resolve installer issues first.

我正在寻找使用 WiX 检测、引导、安装、升级和卸载 SQL Express 2012 的完整示例(尽管部分也很有用).

I'm looking for a full-up example of detecting, bootstrapping, installing, upgrading and uninstalling SQL Express 2012 using WiX (although partials will be useful, too).

此外,我目前在网络上发现的大多数检测逻辑都使用注册表项.但是,Microsoft 建议改用 WMI(请参阅 http://blogs.msdn.com/b/sqlexpress/archive/2006/07/29/faq-detecting-sql-server-2005-using-wmi.aspx).使用 WiX 可以吗?

Also, most of the detection logic I've found so far on the web uses registry keys. However, Microsoft recommends using WMI instead (see http://blogs.msdn.com/b/sqlexpress/archive/2006/07/29/faq-detecting-sql-server-2005-using-wmi.aspx). Is that possible using WiX?

推荐答案

这就是我所拥有的,希望对您有所帮助:

This is what I have, hope it helps:

<?define ServerInstall="SomeCondition" ?>

<?define InstanceName = "YOUR_INSTANCE" ?>
<?define SqlWebLink = http://download.microsoft.com/download/5/2/9/529FEF7B-2EFB-439E-A2D1-A1533227CD69/SQLEXPR_x86_ENU.exe ?>

<Variable Name="SqlVariable" Type="string" Value="/SAPWD=some_password" Hidden="yes" />

<!-- Read SQL Server keys to find current instance and version -->
<util:RegistrySearch
  Id="SqlInstanceKeyFound"
  Root="HKLM" Key="SOFTWAREMicrosoftMicrosoft SQL ServerInstance NamesSQL" Value="$(var.InstanceName)"
  Result="exists" Variable="SqlInstanceKeyFound" />
<util:RegistrySearch
  Id="SqlInstanceKey"
  Root="HKLM" Key="SOFTWAREMicrosoftMicrosoft SQL ServerInstance NamesSQL" Value="$(var.InstanceName)"
  Variable="SqlInstanceKey" After="SqlInstanceKeyFound" Condition="SqlInstanceKeyFound" />
<util:RegistrySearch
  Id="SqlInstanceFound"
  Root="HKLM" Key="SOFTWAREMicrosoftMicrosoft SQL Server[SqlInstanceKey]"
  Result="exists" Variable="SqlInstanceFound" After="SqlInstanceKey" Condition="SqlInstanceKeyFound" />
<util:RegistrySearch
  Id="SqlVersion"
  Root="HKLM" Key="SOFTWAREMicrosoftMicrosoft SQL Server[SqlInstanceKey]Setup" Value="Version"
  Variable="SqlVersion" After="SqlInstanceKey" Condition="SqlInstanceFound" />

<PackageGroup Id="Sql2012Express">
  <!--
    SQL Server 2012 Express - Install new instance
    http://msdn.microsoft.com/en-us/library/ms144259.aspx
    SQL Server Express requires WIndows Installer 4.5
    RepairCommand="/ACTION=Repair /INSTANCENAME=$(var.InstanceName) /Q /HIDECONSOLE"
  -->
  <ExePackage Id="Sql2012Express"
    DisplayName="SQL Server 2012 Express"
    Cache="yes"
    Compressed="no"
    PerMachine="yes"
    Permanent="no"
    Vital="yes"
    Name="RedistSQLEXPR_x86_ENU.exe"
    SourceFile="..PackagesSQLEXPR_x86_ENU.exe"
    DownloadUrl="$(var.SqlWebLink)"
    InstallCommand="/ACTION=Install /INSTANCENAME=$(var.InstanceName) /FEATURES=SQL /SECURITYMODE=SQL [SqlVariable] /TCPENABLED=1 /SQLSVCACCOUNT=&quot;NT AUTHORITYNETWORK SERVICE&quot; /SQLSVCSTARTUPTYPE=Manual /SQLSYSADMINACCOUNTS=BUILTINAdministrators /ADDCURRENTUSERASSQLADMIN=FALSE /Q /HIDECONSOLE /SkipRules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms"
    UninstallCommand="/Action=Uninstall /INSTANCENAME=$(var.InstanceName) /FEATURES=SQL /Q /HIDECONSOLE"
    DetectCondition="SqlInstanceFound"
    InstallCondition="$(var.ServerInstall)">
    <ExitCode Value ="3010" Behavior="forceReboot" />
    <dep:Provides DisplayName="Net2 SQL Server 2012 Express" Key="SQLServer2012Express,$(var.InstanceName)" Version="11.0.3000.0" />
  </ExePackage>

  <!--
    SQL Server 2012 Express - Upgrade existing pre-SQL 2012 instance
  -->
  <ExePackage Id="Sql2012ExpressUpgrade"
    DisplayName="SQL Server 2012 Express Upgrade"
    Cache="no"
    Compressed="no"
    PerMachine="yes"
    Permanent="yes"
    Vital="yes"
    Name="RedistSQLEXPR_x86_ENU.exe"
    SourceFile="..PackagesSQLEXPR_x86_ENU.exe"
    DownloadUrl="$(var.SqlWebLink)"
    InstallCommand="/ACTION=Upgrade /INSTANCENAME=$(var.InstanceName) /Q /HIDECONSOLE /SkipRules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms"
    DetectCondition="NOT (SqlInstanceFound AND (SqlVersion &lt; v11.0.0.0))"
    InstallCondition="$(var.ServerInstall)">
    <ExitCode Value ="3010" Behavior="forceReboot" />
  </ExePackage>

  <!--
    SQL Server 2012 SP1 Express - Upgrade existing SQL 2012 instance to SP1
  -->
  <ExePackage Id="Sql2012ExpressEditionUpgrade"
    DisplayName="SQL Server 2012 SP1 Express Patch"
    Cache="no"
    Compressed="no"
    PerMachine="yes"
    Permanent="yes"
    Vital="yes"
    Name="RedistSQLEXPR_x86_ENU.exe"
    SourceFile="..PackagesSQLEXPR_x86_ENU.exe"
    DownloadUrl="$(var.SqlWebLink)"
    InstallCommand="/ACTION=Patch /INSTANCENAME=$(var.InstanceName) /Q /HIDECONSOLE /SkipRules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms"
    DetectCondition="NOT (SqlInstanceFound AND (SqlVersion &gt; v11.0.0.0) AND (SqlVersion &lt; v11.0.3000.0))"
    InstallCondition="$(var.ServerInstall)">
    <ExitCode Value ="3010" Behavior="forceReboot" />
  </ExePackage>

您需要更改安装命令以符合您的要求.

You would need to change the install commands to match your requirements.

相关文章