Reading Installer Public Properties from a file.  
Author Message
Adrigo Gallus





PostPosted: ClickOnce and Setup & Deployment Projects, Reading Installer Public Properties from a file. Top

We create Windows Installers using Visual Studio Deployment projects. In out Continuous Integration environment, we do a silent install of the newly created installer, as follows -

>> msiexec /i /passive myinstaller.msi USERNAME="foo" DBSTRING="mydb"

However, what we want to do is this -

>> msiexec /i /passive myinstaller.msi PROPERTY_FILE="myprops.txt"

Where, the property file contains the properties we would have been passing from the commandline, i.e.,

>> type myprops.txt

USERNAME="foo"

DBSTRING="mydb"

After reading a post and this article, this is what I understand -

I can create a custom action that reads the file, and creates the properties using the MsiSetProperty function. But, because of the Visual Studio Deployment Project model, I might not be able to set properties like TARGETDIR, but this is alright because all my properties are essentially, values that must be placed in the application configuration file.

Since I want to create a custom action (let call is prop-file-reader) that can be used in all installers we create, I want to create it as an assembly and bundle it in all our installers. Then, the Installer will have a custom action that will invoke this assembly. But, the MsiSetProperty function requires a MSIHANDLE* hProduct, to create properties in it. I can get it using the MsiOpenPackage function, but that requires the path of the installer. My questions are -

  1. Is there a Public property that holds the current path of the installer, that I can pass to the custom action
  2. Is my thinking correct After I run this custom action, can my other custom actions (say written in VBScript) access the properties (say USERNAME, DBSTRING) if I use the CustomActionData property of the custom action
  3. Must the prop-file-reader custom action be written only in C++ Can I use any of the .NET languages, VBScript or JScript
  4. Also, if I don't want to use the CustomActionData property to explicitly name the properties I want to pass to the custom action, is there any other way to access an arbitrary property in a custom action

Thanks.



Windows Forms6  
 
 
PhilWilson





PostPosted: ClickOnce and Setup & Deployment Projects, Reading Installer Public Properties from a file. Top

The MSIHANDLE in a C++ action gets passed in by MSI. You don't supply it, so I don't think you need 1.

3, VbScript and installer classes work, so do executables, although installer classes aren't recommended.

4. You don't get a choice in Visual Studio setup projects.

My inclination would be to forget custom actions and use a launcher program that reads a file and fires off the msiexec command with the property values.



 
 
David Guyer MS





PostPosted: ClickOnce and Setup & Deployment Projects, Reading Installer Public Properties from a file. Top

Also,

I'm pretty sure that an installer class can't set values in the Windows Installer. The data flow is only one way, from Windows Installer to the custom action. This may be because it is a 'deferred' custom action, but I'm not sure.

A native custom action can do this, but you might find that you can't send set the properties unless you make it not be deferred. You'd have to edit the built MSI to do this, this is just not a scenario we support very well right now.

Phil has proposed another possible workaround.



 
 
Adrigo Gallus





PostPosted: ClickOnce and Setup & Deployment Projects, Reading Installer Public Properties from a file. Top

Thanks for the replies.

I see what you are saying about figuring out some way to pass the properties from the command line itself, but we would like really to give the end-user an installer, and if necesary a properties file. But nothing more.




 
 
PhilWilson





PostPosted: ClickOnce and Setup & Deployment Projects, Reading Installer Public Properties from a file. Top

Visual Studio setup projects don't let you run code that early in the installation sequence, and you'd need custom action code to do what you're asking. Other tools that generate MSI files can do this, but you're not using them. That's why I suggested a launcher that reads a file and runs msiexec with your command line. If you use a zip tool you can create a self-extracting exe that will automatically extract the files and run your launcher program, so the end-user experience is pretty simple. They just run an exe and then it's all automatic.