
kiran.thonse1.5524941654480437E12 asked a question.
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:
- Managed to use cabarc to extract the data1.cab contents on to a local folder using:
- Managed to replace the xml file in the files folder
- Managed to repack the cab file using:
- Managed to inject it back into the msi using:
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.
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.
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 ?
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 ?
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 ?
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 ? )
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.
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 ?
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 ?
http://kb.acresso.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=Q107253