Loading
Replace a single file embedded in an MSI
First off, I would like to say I am no installer guy. Only now am I learning a little about MSIs, tables etc.. so please bear with me if I sound too newbish.

 

I am faced with a situation like this:

 

There is an xml file that is to be installed by one of the products am working on. This XML file is not fixed in the sense that, it has to be generated fresh for each customer. As such, I already have the ability to use InstallShield standalone component and crank out a new installer using the new xml file each time. However, this would need me to maintain all the input files, merge modules , prqs needed by the installer ( times the no. of version ofs the product ). I would like to simplify this so that the installer would be generated with a dummy xml file during build time, but then on demand, this installer will be massaged and injected with the new xml file.

 

With that background, I did some research on various tools and this is what I got done so far:

 

     

  • Managed to use msidb to extract the data1.cab using:
msidb.exe" -d test.msi -x Data1.cab

 

  • Managed to use cabarc to extract the data1.cab contents on to a local folder using:
cabarc X Data1.cab *.* c:\tmp\files\

 

  • Managed to replace the xml file in the files folder
  • Managed to repack the cab file using:
cabarc N Data1.cab c:\tmp\files\*.*

 

  • Managed to inject it back into the msi using:
rem remove stream first

 

msidb.exe" -d test.msi -k Data1.cab

 

rem now add it

 

msidb.exe" -d test.msi -a Data1.cab

 

 

I see that the msi is created and when I use orca to open it, I see the media table having the data1.cab entry. However, when I run the msi, it comes up with an error that a file is not found and aborts installation.

 

I have seen quite a few posts with a similar situation, but haven't really seen a solution that works. Some recommend using transforms, some recommend pulling that xml file out of the CAb and use from elsewhere, so it could be updated without repacking the CAb etc..

 

Any help would be appreciated. Am willing to try what I can. Have most of the tools like CAB SDK, Installer SDK, Wi*.vbs files, orca.

  • 0_M Urman (Flexera Software)

    This approach is going to be full of difficult steps like you've seen. The failure is probably due to the order or keys of the files in the CAB changing, as MSI cares about this. I'd suggest one of two things. If the XML file is similar enough in all scenarios that it only needs a small piece of it updated (say an attribute's value), it may be worth exploring using the XML Changes view to update a base file to have what you need by updating properties, or even transforming the XML changes with a transform.

     

    If the differences aren't so simple and you truly do need a separate file, perhaps you could add your dummy file as a Support File, then restream the updated one into its entry in the ISSetupFile table as your only post-build step. You'd have to update any logic in your installer to actually copy it into place (and remove it at uninstall) if you go with this route, but it'll make the post-build part much more approachable.

     

    As an aside, when you're making these surgical updates post-build, don't forget to take care to update the Package Code (of the summary information stream), and possibly the ProductCode and/or UpgradeCode properties as appropriate.
    Expand Post
  • ok. I figured how to do this:

     

    Here is what I am doing in case it helps someone:

     

    It's a batch file using the baseline from here .

     

     

    @ECHO OFF

     

    @ECHO.

     

    @ECHO Updating MSI file with new files

     

    @ECHO.

     

    @ECHO Remove target output file

     

    rmdir /S /Q dump

     

    @ECHO unzip MSI

     

    msiexec /a Input.msi TARGETDIR="c:\tmp\TestPackaging\dump" /quiet

     

    @ECHO press any key when installation is done

     

    rem pause

     

    @ECHO replace xml file

     

    copy .\some.xml ".\dump\CommonAppData\{Company Name}\{Product Name}\some.xml"

     

    @ECHO Update MSI information from source tree

     

    CScript //nologo WiFilVer.vbs .\dump\Input.msi

     

    CScript //nologo WiFilVer.vbs .\dump\Input.msi /U

     

    @ECHO Copy original file to new output file

     

    COPY /Y ".\dump\Input.msi" ".\dump\Output.msi"

     

    REM @ECHO Create a single cabinet file with all your files

     

    REM CScript //nologo WiMakCab.vbs ".\dump\Output.msi" Data1 /C

     

    @ECHO Create and embed the file cabinet

     

    CScript //nologo WiMakCab.vbs ".\dump\Output.msi" Data1 /C /U /E /S

     

    DEL /Q "Data1.CAB"

     

    DEL /Q "Data1.INF"

     

    DEL /Q "Data1.RPT"

     

    DEL /Q "Data1.DDF"

     

    @ECHO Done

     

    PAUSE

     

     

    This works fine. Question I have is with the first step i.e. admin install using msiexec /a.

     

    Is this adminstrative install gauranteed to install all the files ? Reason being, there some optional command lines I can use to enable/disable certain features. Is it safe to use the msiexec /a ?
    Expand Post
  • MichaelU, thanks so much for the reply.

     

    I figured how to do this, although I have a question towards the end. Also not sure if your concerns are still valid with the approach I have listed below ( especially the product code , package and upgrade codes ). Would appreciate your insight into this.

     

    Here is what I am doing in case it helps someone:

     

    It's a batch file using the baseline from here .

     

     

    @ECHO OFF

     

    @ECHO.

     

    @ECHO Updating MSI file with new files

     

    @ECHO.

     

    @ECHO Remove target output file

     

    rmdir /S /Q dump

     

    @ECHO unzip MSI

     

    msiexec /a Input.msi TARGETDIR="c:\tmp\TestPackaging\dump" /quiet

     

    @ECHO press any key when installation is done

     

    rem pause

     

    @ECHO replace xml file

     

    copy .\some.xml ".\dump\CommonAppData\{Company Name}\{Product Name}\some.xml"

     

    @ECHO Update MSI information from source tree

     

    CScript //nologo WiFilVer.vbs .\dump\Input.msi

     

    CScript //nologo WiFilVer.vbs .\dump\Input.msi /U

     

    @ECHO Copy original file to new output file

     

    COPY /Y ".\dump\Input.msi" ".\dump\Output.msi"

     

    REM @ECHO Create a single cabinet file with all your files

     

    REM CScript //nologo WiMakCab.vbs ".\dump\Output.msi" Data1 /C

     

    @ECHO Create and embed the file cabinet

     

    CScript //nologo WiMakCab.vbs ".\dump\Output.msi" Data1 /C /U /E /S

     

    DEL /Q "Data1.CAB"

     

    DEL /Q "Data1.INF"

     

    DEL /Q "Data1.RPT"

     

    DEL /Q "Data1.DDF"

     

    @ECHO Done

     

    PAUSE

     

     

    This works fine. Question I have is with the first step i.e. admin install using msiexec /a.

     

    Is this adminstrative install gauranteed to install all the files ? Reason being, there some optional command lines I can use to enable/disable certain features. Is it safe to use the msiexec /a ?
    Expand Post
  • ok. I figured how to do this, although I have a question towards the end

     

    Here is what I am doing in case it helps someone:

     

    It's a batch file using the baseline from here .

     

     

    @ECHO OFF

     

    @ECHO.

     

    @ECHO Updating MSI file with new files

     

    @ECHO.

     

    @ECHO Remove target output file

     

    rmdir /S /Q dump

     

    @ECHO unzip MSI

     

    msiexec /a Input.msi TARGETDIR="c:\tmp\TestPackaging\dump" /quiet

     

    @ECHO press any key when installation is done

     

    rem pause

     

    @ECHO replace xml file

     

    copy .\some.xml ".\dump\CommonAppData\{Company Name}\{Product Name}\some.xml"

     

    @ECHO Update MSI information from source tree

     

    CScript //nologo WiFilVer.vbs .\dump\Input.msi

     

    CScript //nologo WiFilVer.vbs .\dump\Input.msi /U

     

    @ECHO Copy original file to new output file

     

    COPY /Y ".\dump\Input.msi" ".\dump\Output.msi"

     

    REM @ECHO Create a single cabinet file with all your files

     

    REM CScript //nologo WiMakCab.vbs ".\dump\Output.msi" Data1 /C

     

    @ECHO Create and embed the file cabinet

     

    CScript //nologo WiMakCab.vbs ".\dump\Output.msi" Data1 /C /U /E /S

     

    DEL /Q "Data1.CAB"

     

    DEL /Q "Data1.INF"

     

    DEL /Q "Data1.RPT"

     

    DEL /Q "Data1.DDF"

     

    @ECHO Done

     

    PAUSE

     

     

    This works fine. Question I have is with the first step i.e. admin install using msiexec /a.

     

    Is this adminstrative install gauranteed to install all the files ? Reason being, there some optional command lines I can use to enable/disable certain features. Is it safe to use the msiexec /a ?
    Expand Post
  • 0_M Urman (Flexera Software)

    Administrative installs should create a full image of the contents of the MSI; feature filtering happens when that image is run to install it on a target machine. As for the package and product code question, it's a rule that can be broken, but only carefully, when you know 100&37; that the slightly different packages will never be installed on the same computer, and probably other caveats I'm not thinking of right now. So don't do it lightly. Take a look at the windows installer help topics on this, including Package Codes .
    Expand Post
  • Thanks for the heads up. Appreciate it. I will look into the link you pointed out. Skimming through it, it seems that what I am doing is messy.

     

    I am starting to like the idea of using an mst. Some questions I have:

     

    1. Can the mst file generation ( which references the new xml file ) be automated/scripted ? i.e. I need to crank this all up without using an IDE.

     

    2. Also, I would like to have a single installer EXE. Can the mst file be embedded into the EXE ? Again, if yes, can this step of embedding the mst into the EXE be automated/scripted ( using IsCmdBld / vbscripting or other utils ? )
    Expand Post
  • 0_M Urman (Flexera Software)

    It's certainly possible to script the creation of transforms. For the complexity you're likely to be dealing with, it may be reasonable to use Windows Installer automation, but it should also be possible to use InstallShield's automation layer. I don't think it would be feasible to do it with command lines alone.

     

    As for packing it back up in a single EXE, we don't offer any way to do this after the build (except pure InstallScript projects with the ReleasePackager exe), sorry.
    Expand Post
  • " MichaelU wrote:

     

    As for packing it back up in a single EXE, we don't offer any way to do this after the build (except pure InstallScript projects with the ReleasePackager exe), sorry. "

     

    Thanks for the reply ! I need to have an EXE installer since I have PRQ dependencies. So ,that practically kills all possibilities of being able to do this even if I could get the xml into the MSI using a transform or otherwise :(

     

    Thanks again for your help. I bumped into another thread where a similar scenario was presented where the OP had all the files needed for bundling but that last step wasn't possible since there wasn't a tool that could do this. Is this something that is planned for a future release ?
    Expand Post
  • I have been thinking about the XML Changes view. I have managed to manipulate the XML file contents with a value of a property. Now, all I have to do is change the property value. I again managed to change the property at runtime by configuring the CmdLine key in the setup.exe setup.ini section ( using the IDE ).

     

    I could now theoretically do the same using setupini.exe isn't it ? Is there a setupini.exe for IS 2009 ? I tried the one for IS 10.5 and although it said it successfully modified the setup.exe, the setup.exe now fails to run ( "error reading setup initialization file" generated when I run the exe ). Any clues ?
    Expand Post
10 of 11

Loading
Replace a single file embedded in an MSI