Bogdan Verbenets
Bogdan Verbenets

Reputation: 26936

read a file inside of a setup package

I have a file which I want to use during install. It contains some SQL. This file is not used by the installed application itself, so I don't want it to be installed to the client machine, I want it to be a part of the setup package like my custom action DLLs that I specify using Binary element. But how do I read that file if I embed it into the setup package? Are there any built-in WiX/DTF functions for that? Or maybe I should embed that file in another way?

Upvotes: 1

Views: 415

Answers (3)

Bogdan Verbenets
Bogdan Verbenets

Reputation: 26936

The best way I've discovered for myself - create a Properties file for the WiX custom actions library and add all SQL there. No additional actions should be done for the SQL to be available in the custom actions! :)

Upvotes: 0

Sunil Agarwal
Sunil Agarwal

Reputation: 4277

I had the same requirement. You can deploy that file at some location and then easily read, edit, execute from that location

Upvotes: 0

Stephen Connolly
Stephen Connolly

Reputation: 1639

You need to do something along the following lines:

  • use the <binary> element to include the file as a stream in the Binary table of your package.
  • Stream the file out of the binary table to a temp file in an immediate custom action, and store the location of the temp file in a property, e.g. CleanupSQLFile
  • Do whatever it is you need to do with the file
  • Clean up the file once you are done with it. If you need to clean up the file as part of a deferred or commit operation then you will need to use a Action called CleanupSQLFile and read in the file location from the CustomActionData property. The Property and CustomAction must have the same name

There's an example of streaming a file from the binary table on InstallSite.

Upvotes: 2

Related Questions