Wix可以默默地不覆盖数据库

时间:2013-02-07 04:12:42

标签: database installer wix

Wix显然可以提示/告诉用户存在数据库,并让他们选择覆盖或取消安装。不幸的是,用户无法指定“不覆盖”并继续安装。

因此,Wix可以默默地不覆盖数据库吗?如果数据库存在,只需忽略并继续执行下一条指令。

如果没有,是否有其他方法可以实现重新安装需要发生且数据库已经到位的事实?

目前我的Wix片段如下所示:

<Fragment>
    <ComponentGroup Id="COMPG_MyProductDatabase" Directory="TARGETDIR">
      <Component Id="COMPG_MyProductDatabase.sql" Guid="{...}">
        <File Id="FILE_MyProductDatabase.sql" Source="..\MyProduct.Cache.Database\MyProduct.Deployment.sql" Name="MyProduct.Deployment.sql" KeyPath="yes" Checksum="yes"/>
      </Component>

      <Component Id='COMP_MyProductDatabase' Guid='{...}'>
        <CreateFolder/>
        <sql:SqlDatabase Id='DB_MyProductDatabase' Database='MyProduct' Server='[PROP_DATABASESERVERNAME]'
          CreateOnInstall='yes' DropOnUninstall='no' ContinueOnError='yes' ConfirmOverwrite='yes'>
          <sql:SqlScript Id='SQL_MyProductDatabase' BinaryKey='FILE_MyProductDatabase' ExecuteOnInstall='yes' />
        </sql:SqlDatabase>
      </Component>
   </ComponentGroup>
    <Binary Id='FILE_MyProductDatabase'  SourceFile='..\MyProduct.Cache.Database\MyProduct.Deployment.sql' />
</Fragment>

1 个答案:

答案 0 :(得分:2)

将数据库创建移动到SQL脚本中,然后使用SQL语句执行条件逻辑。更改SqlDatabase元素以连接到“master”以使其正常工作。