如何在从安装程序执行的 sql 文件中使用 WiX 属性? [英] How can I use WiX properties in a sql file executed from the installer?

查看:12
本文介绍了如何在从安装程序执行的 sql 文件中使用 WiX 属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WiX 安装项目,我正在根据 Wise 以前的安装程序重写该项目.在 Wise 中,您可以添加要执行的文件(我们使用的是 sql 脚本文件),并且它有一个替换选项卡,用于指定文件中的某些文本要替换为静态文本或 Wise 属性.

I have a WiX install project that I am rewriting based on our previous installers from Wise. In Wise, you can add files for it to execute (ours used sql script files) and it had a replace tab that specified certain text in the file to be replaced with either with static text or a Wise property.

我想知道这在 WiX 中是否可行?

I am wondering if this is possible in WiX?

示例:

use [SQLDBNAME]
SELECT *
FROM Employee

WiX 将在哪里读取文件并将 [SQLDBNAME] 替换为 WiX 属性表中设置的值?

Where WiX would read the file and replace the [SQLDBNAME] with the value set in WiX's properties table?

推荐答案

属性替换适用于 SqlString 元素,您可以在其中将 SQL 字符串字面定义为属性值.但是,它不适用于 SqlScript 元素,您将整个 SQL脚本文件到二进制文件.这完全取决于您的 SQL 查询的复杂程度.

The Property replacement works for SqlString element, where you define the SQL string literally as a value of the attribute. However, it doesn't work for SqlScript element, where you put the entire SQL script file to Binary. It all depends on how complex is your SQL queries.

在使用 SqlString 时,不要忘记 SQL 使用 [] 来转义它自己的保留字.因此,在这种情况下,您应该像这样转义 MSI 属性:[\[][\]].

When using SqlString, don't forget that SQL uses [ and ] to escape its own reserved words. So you should escape the MSI properties like this in that case: [\[] and [\]].

希望这会有所帮助.

这篇关于如何在从安装程序执行的 sql 文件中使用 WiX 属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆