I want to read the content of a file in WiX, so that I can use them during the installation [they are SQL scripts that I want to execute with a custom action]
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="cmp35BC97AC12F21A6F6154759C2D9B5430" Guid="*">
<File Id="filDEDB241BDDF1A0CD0B001190398F5F5F" KeyPath="yes" Source="SourceDir\TestScript - Copy.sql" />
</Component>
<Component Id="cmp221D9003B2C58612888DBC0D1CEBC730" Guid="*">
<File Id="filF6EA2F11A51AF10E1517FFB9152307EE" KeyPath="yes" Source="SourceDir\TestScript.sql" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="AgentX.Database.Installer">
<ComponentRef Id="cmp35BC97AC12F21A6F6154759C2D9B5430" />
<ComponentRef Id="cmp221D9003B2C58612888DBC0D1CEBC730" />
</ComponentGroup>
</Fragment>
</Wix>
I have used this code to check the content of the file:
var fileView = session.Database.OpenView("SELECT * FROM File");
fileView.Execute(null);
foreach (Record fileRec in fileView)
{
session.Log("\t{0}", fileRec["FileName"]);
}
I want to read the sql files, embedded in the MSI.
SqlScript: I almost never use this feature, but WiX has a SqlScript Element that should be able to do the job for you. I keep wondering if SQL scripts should be run by an application and not by a setup, but that is another discussion.
Snippet (from WiX tutorial - downloadable sample towards bottom):
Links:
SQL: