Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dynamically altering an MSI from within C#.NET

718 views
Skip to first unread message

RicW

unread,
Aug 22, 2005, 4:18:04 AM8/22/05
to
I have an server application that needs to alter an MSI at runtime to create
an install set for the client software. This will involve editing the MSI to
add an ini file or such like that will contain configuration information
dependant on setting chosen in the server app.

Unfortunately I know nothing about MSIs and am unsure whether I need to edit
database tables manually, or if there is an API I can use from C#. Either
way, could someone give me some nudges in the right direction?

Thanks

Rage

unread,
Aug 22, 2005, 12:04:36 PM8/22/05
to
An easy way would be to use Wix. Use C# to edit Wix source files according to
what you want (the files are in xml format) and then call the Wix executables
to generate the msi file for you.

If this does not work for you, you can look at the source for Wix, which
would then tell you how to manipulate msi's directly from C#.

Wix can be found at http://wix.sourceforge.net .

Hope that helps!

/ Rage

RicW

unread,
Aug 22, 2005, 12:19:03 PM8/22/05
to
Thanks - I assume from this that Wix is freely distributable along with my
application (I'm no expert when it comes to the legal jargon in licenses)?

Rage

unread,
Aug 23, 2005, 4:21:03 AM8/23/05
to
Wix is distributed under the Common Public License. I cannot give you any
legal advice, but my understanding is that you're able to distribute Wix
freely along with your product.

You should probably seek advice from a lawyer if you aren't sure after
you've read the license text.

"Martin v. Löwis"

unread,
Aug 24, 2005, 3:07:12 AM8/24/05
to
RicW wrote:
> I have an server application that needs to alter an MSI at runtime to create
> an install set for the client software. This will involve editing the MSI to
> add an ini file or such like that will contain configuration information
> dependant on setting chosen in the server app.

You haven't been too specific what kinds of change might be
necessary/acceptable. For example, to add a file, you typically rebuild
the MSI file from scratch. For altering it, it would be best if you
could express the modifications in terms of properties (key/value
pairs), and if you then arrange to use these properties in a uniform
way.

For example, adding registry keys to contain the property settings
would be fairly easy - if it *must* be an INI file, you could create
a custom action to generate/modify it.

I would advise against using Wix for this kind of application. Instead,
Installer has a convenient API which you can readily use from C#.

Regards,
Martin

Fyodor Koryazhkin

unread,
Aug 28, 2005, 6:14:21 AM8/28/05
to
Hello RicW,
By my opinion all ways mentioned above are too complicated and not reliable.
Creating a complete MSI package on the fly is too dangerous since one little
mistake can crash whole system.
You have two other options. They are not so flexible but may be trusted:
1. You can use transforms to apply any changes to already created package.
2. You can use set of predifined public properties that can rule your installation.
At the time of the launching the package you can pass properties to the MSI
and so to control your installation.

Regards
Fyodor.

Richard [Microsoft Windows Installer MVP]

unread,
Aug 29, 2005, 5:27:50 PM8/29/05
to
[Please do not mail me a copy of your followup]

=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= <mar...@v.loewis.de> spake the secret code
<430c1ca0$0$13071$9b62...@news.freenet.de> thusly:

>I would advise against using Wix for this kind of application. Instead,
>Installer has a convenient API which you can readily use from C#.

Well, not *quite* so readily. I mean, using an individual function or
two is not so painful, but anything beyond the most basic of tasks is
tedious. If you want to manipulate MSI files from C#, use the interop
library taht I wrote:
<http://sourceforge.net/project/showfiles.php?group_id=40188&package_id=110212>

It organizes the API into objects that follow the automation object
model and handles all the management of the underlying unmanaged
handles for you via IDisposable.
--
"The Direct3D Graphics Pipeline"-- code samples, sample chapter, FAQ:
<http://www.xmission.com/~legalize/book/>
Pilgrimage: Utah's annual demoparty
<http://pilgrimage.scene.org>

0 new messages