我正在尝试使用Wix Installer 3.9从.bak文件(数据库备份文件)中还原SQL Server数据库,但不幸的是它没有成功。以下是我的测试代码:
<Fragment>
<Binary Id="PHRBackupBin" SourceFile="Database/PHR.bak"></Binary>
<!--<util:User Id="SQLUserSA" Name="[DB_USER]" Password="[DB_PASSWORD]"></util:User>-->
<util:User Id="SQLUserSA" Name="sa" Password="sa"></util:User>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="SqlComponent" Guid="8A1C82DB-1DD3-4FB5-8600-4F370FE1E04B">
<Condition>NOT Installed</Condition>
<sql:SqlDatabase Id="SqlServerDatabase" Database="PHR" Server="." CreateOnInstall="yes" DropOnUninstall="yes" User="SQLUserSA" ContinueOnError="no" Instance="SQLEXPRESS">
<sql:SqlScript Id="PHRBackup" ExecuteOnInstall="yes" ExecuteOnUninstall="no" BinaryKey="PHRBackupBin" ContinueOnError="no" />
</sql:SqlDatabase>
<CreateFolder/>
</Component>
</DirectoryRef>
<ComponentGroup Id="DatabaseConfiguration">
<ComponentRef Id="SqlComponent"></ComponentRef>
</ComponentGroup>
如果我用.sql(SQL脚本)文件替换该文件,则上述安装程序可以成功运行。我还尝试编写脚本文件来恢复数据库,但没有成功。我想问问社区如何从wix安装程序运行.bak文件。
提前感谢。