简体   繁体   English

WiX Installer-如何从与.msi相同位置的文件夹中读取sql文件内容

[英]WiX Installer - how to read sql file content from a folder which reside at same location as .msi

I want to invoke custom action to execute set of .sql files against given database. 我想调用自定义操作以针对给定的数据库执行.sql文件集。 I am able to do that using custom action code(in c#) if I hardcode path of folder where my sql files are available. 如果我可以将sql文件所在的文件夹的路径硬编码,则可以使用自定义操作代码(在c#中)执行此操作。

I want to put this sql scripts folder in same location where my .msi is present. 我想将此sql脚本文件夹放在存在.msi的相同位置。 How can I access/find this folder-path from custom action during the time of installation? 在安装期间,如何通过自定义操作访问/查找此文件夹路径?

I am using Wix 3.6. 我正在使用Wix 3.6。 I am using dot net bootstrapper to create my setup.exe. 我正在使用点网引导程序创建我的setup.exe。

The SqlScript element in the WiX toolset may do a lot of what you are asking for. WiX工具SqlScript元素SqlScript您的要求。 It actually stores the scripts as Binary streams in the MSI instead of relying on files relative to the MSI. 它实际上将脚本作为Binary流存储在MSI中,而不是依赖于与MSI相关的文件。 This is an important design decision because there are many cases where your MSI will execute but not have access to the original source media so it would not find the scripts. 这是一项重要的设计决策,因为在许多情况下,您的MSI将执行但无法访问原始源媒体,因此无法找到脚本。 For example, repair operations can be launched from the cached MSI package. 例如,可以从缓存的MSI包中启动修复操作。 If your custom action was to repair, it would need the original media to get the scripts. 如果您的自定义操作是修复,则将需要原始媒体来获取脚本。 This is not very desirable. 这不是很理想。

If you really want to go down this path, then you'll want to look at using the SourceDir directory to get the "source location" of your MSI. 如果您真的想走这条路,那么您将需要使用SourceDir目录来获取MSI的“源位置”。 As noted above, the source media may not always be available and SourceDir will be blank in those cases. 如上所述,源媒体可能并不总是可用,并且在这些情况下SourceDir将为空白。 To force SourceDir to be set, you'll need to add a ResolveFiles action. 要强制设置SourceDir ,您需要添加ResolveFiles操作。 Be careful when scheduling ResolveFiles because that will require the original media. 安排ResolveFiles时要小心,因为这将需要原始媒体。 If that can't be found, the user will be prompted to insert it again. 如果找不到,将提示用户再次插入。

The worst case of poor sequencing of ResolveFiles is a prompt from source when the user is attempting to uninstall their product. ResolveFiles排序不正确的最坏情况是,当用户尝试卸载其产品时,系统提示您。 User's are trying to get your application of the machine and they are prevented unless they can find how they originally installed it. 用户正在尝试获取您的计算机应用程序,除非找到原始安装方式,否则将阻止用户使用它们。 Good way to really upset your users. 真正打乱用户的好方法。 :) :)

I highly recommend looking at the SqlScript element instead or the source code if you are really interested. 如果您确实有兴趣,我强烈建议您查看SqlScript元素或源代码。 It's in the WiX toolset at src\\ca\\serverca (look for files with "sql" in the name below there). 它位于src \\ ca \\ serverca的WiX工具集中(在下面的名称中查找带有“ sql”的文件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM