WIX自定义操作SQL文件 - SQL组件尚未安装



我在将其作为架构文件运行之前,尝试更改SQL文件。问题是该文件还不存在(if(file.exist())。当SQL二进制文件已经存在时,并且在SQL Creation运行之前,我可以依赖运行自定义操作吗?这是代码:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
 xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension">

    <Binary Id="SqlScriptSQLAuthentication"  SourceFile="..SQLCreateSchema.sql" />
    <Binary Id="SqlScriptIntegratedAuthentication"  SourceFile="..SQLCreateSchema.sql" />
    <CustomAction Id="ChangeSqlScript"
          BinaryKey="Installer.CA"
          DllEntry="ChangeSqlScript"
          Execute="immediate"
          Return="check" 
          Impersonate='yes'/>
    <InstallExecuteSequence>          
      <Custom Action="ChangeSqlScript" After="InstallFinalize">NOT Installed AND VersionNT</Custom>
    </InstallExecuteSequence>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ROOTFOLDER">
        <Directory Id="INSTALLDIR" Name="!(loc.ProductNameFolder)">
        </Directory>
      </Directory>
      <Component Id='SqlComponent.SQLAuthentication' Guid='665D641C-3570-4b96-9CA5-2B4C12594A35' KeyPath='yes'>
        <Condition><![CDATA[USEINTEGRATEDSECURITY<>1]]></Condition>
        <sql:SqlDatabase Id='SqlDatabase.SQLAuthentication' Database='[DATABASE_NAME]' User='SQLUser' Server='[DATABASE_SERVER]' CreateOnInstall='yes' DropOnUninstall='no' ContinueOnError='no' />
        <sql:SqlScript Id='SqlScriptSQLAuthentication' BinaryKey='SqlScriptSQLAuthentication' SqlDb='SqlDatabase.SQLAuthentication' ExecuteOnInstall='yes' />
      </Component>
      <Component Id='SqlComponent.IntegratedAuthentication' Guid='E5DF48AE-2338-4029-9FDF-8DAA6AD0216D' KeyPath='yes'>
        <Condition>USEINTEGRATEDSECURITY = 1</Condition>
        <sql:SqlDatabase Id='SqlDatabase.IntegratedAuthentication' Database='[DATABASE_NAME]' Server='[DATABASE_SERVER]' CreateOnInstall='yes' DropOnUninstall='no' ContinueOnError='no' />
        <sql:SqlScript Id='SqlScriptIntegratedAuthentication' BinaryKey='SqlScriptIntegratedAuthentication' SqlDb='SqlDatabase.IntegratedAuthentication' ExecuteOnInstall='yes' />
      </Component>
  </Directory>   

sqlscript文档描述了一个 Sequence属性,您可以用来明确安排操作:

Specifes the order to run the SQL Scripts. It is recommended that rollback 
scripts be scheduled before their complementary execution script. This order 
is also relative across the SqlString element.

相关内容

  • 没有找到相关文章

最新更新