Custom Action script organization
Posted 14 October 2004 - 18:47
In each of our products we have a single monolithic script file that is a collection of script functions. Much code is duplicated between the different installers. The logging function, for instance, shows up in all these files.
This is a maintenance nightmare. If I change one file I have to change them all. I have to be careful of package-specific tweaks that previous maintainers performed on similar functions. I would much rather have a single file containing common code. For instance, I want to extend our logging function. I now have to duplicate my effort to change that function in a dozen different places.
We are missing something. What mechanism should I be using to factor common code in my custom action scripts? Is there an article I can read? Am I in the right forum?
Posted 15 October 2004 - 03:51
You can definately do that if you make your CA DLL in C/C++ just as well as in IS InstallScript.
In your main script file for every installer you have:
UINT __stdcall CustomFunction (MSIHANDLE hModule)
//TODO: Put your SetupAPI routine here
in your "common" folder you will have two files: log.cpp and log.h
log.cpp will look like:
void UpdateLog(int *myLog)
//TODO: Put your log routine here
and finally your log.h will have the following:
void UpdateLog(int *myLog);
Now, all you have to do, is to put log.h/cpp files into "common" folder and access that module from all the installers that require its functions.
Edited by Volynkin, 15 October 2004 - 03:52.
Posted 15 October 2004 - 08:46
Create a merge module (MSM), and use that in all your installs.
Posted 15 October 2004 - 16:56
We have decided that in order to have access to the Installer object, and in order to hire "Install Engineers" that don't need to know how to operate compilers, JScript is the preferred language for CA.
We are developing some expertise in .NET and it would be relatively easy to steal some talent in C#. C and C++ talent is a little harder to come by here.