简体   繁体   中英

Editing packaged file in WiX

WiX newbie here. I'm curious if this approach is possible using WiX.

Problem statement...

I am packaging some SQL files that I want to execute against some parameters that the user will enter at run time. Think connection string information. One of the parameters that the user can enter is the directory where they want the DB to be installed.

Current solution (doesn't work).....

To do this i'm packaging these files using heat. When it sucks in this files one of my SQL files has some tokens in them that a custom action looks for to basically do a find replace in the file. The problem is thatwhile it is indeed doing a find replace it's doing them against the source files that heat sucked in and not the files that exist in the .msi file.

Question 1...

Within the WiX workflow is there a way that via a custom action I can do processing on the files that are stored within the .cab or .msi file? If that is possible can someone show me an example of this?

Question 2 . . .

If question 1 isn't possible the other idea I had was to break the find replace SQL piece and the file install piece into separate msi file. So the first step would be to explode all the files I need into the install directory via one msi. The next msi would execute the SQL piece as at that point the files exist on the file system for me to do editing on. Does this sound like a sane approach to the problem? It could very well be that I'm trying to work around WiX and not with WiX here.

Current code snippets

<Product>
   <!-- This is where this will be installed-->
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="INSTALLFOLDER" Name="ZOLLData">
            <Directory Id="SQLINSTALLFOLDER" Name="Sql" />
        </Directory>
    </Directory>

    <!-- CUSTOM ACTION DEFINITIONS-->
    <CustomAction Id="FindReplaceZEDSTextCA"
                  Return="check"
                  BinaryKey="GemstoneInPremiseInstallerCustomActions.CA.dll"
                  Execute="immediate"
                  DllEntry="FindReplaceText" />



    <!-- Database Information-->
    <util:User Id="SQLUser" Name="[SQLUSERNAME]" Password="[SQLPASSWORD]"/>
    <sql:SqlDatabase Id="MasterDatabase" Database="master"
                        Server="[SQLSERVERNAME]"
                        User="SQLUser"/>


    <InstallUISequence>
        <Show Dialog="SqlConnectionDlg" After="CostFinalize" />
        <Show Dialog="ProgressDlgCustom" After="SqlConnectionDlg"/>
    </InstallUISequence>

    <InstallExecuteSequence>
        <Custom Action="FindReplaceZEDSTextCA" After="InstallFiles">
        </Custom>
    </InstallExecuteSequence>
</Product>

<Fragment>
        <DirectoryRef Id="INSTALLFOLDER" />
    </Fragment>
    <Fragment>
        <ComponentGroup Id="SqlComponents">
            <Component Id="CreateDatabase.sql" Directory="INSTALLFOLDER" Guid="6A2C6088-9302-451C-A01B-02D618D4AC27">
            </Component>
        </ComponentGroup>
    </Fragment>

Thanks in advance.

The problem was the my custom action was set with Execute="immediate". This should have been Execute="deferred".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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