Deployment Custom Action

I have created a Windows Set-up and Deployment Package for an application. Each User will require a database file with different contents specific to them to be installed. So instead of re-building the install package every time I want to just place the unique database file on to the installation cd and have it automatically copied to the users chosen installation locaton.

 I know I am supposed to create a custom installer class to include with the package, but how do you know what target path the user has chosen for the installation i.e. Is it a property that is available when coding the custom install class?  Anyone have an example e.g. Copy app.path\data.mdb        targetpath\data.mdb    
LVL 3
JeffvClaytonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill-HansonCommented:
Yes, you can access any property of the installer from within your custom action class.  

There's a Microsoft help article titled "Walkthrough: Using a Custom Action to Display a Message at Installation" that explains how to create the custom installer class and how to create (and access) custom properties, but it does not explain about the built-in properties available from the installer.  To find those constants, you have to find the article titled "Property Reference" (with the setup project open, just press F1, then enter "Property Reference" in the search window to see the complete list of properties.

Here's the skinny:

(1) In your custom installer class, you need to define an Install method.  This is where you code your custom actions.  This class has access to any properties that you pass to it.  In the example below, I used the SourceDir and UserName properties.  I'll explain how to pass these variables to your custom class in the next step.

(2) After you've added the primary output from your custom action class (a dll file) to the Install custom action, select the "Primary output from ..." line then select the CustomActionData property (see image).  This is where you pass the properties to your class.  In my example, I used SourceDir and UserName, so my CustomActionData property looks like this:

/SourceDir="[SourceDir]\" /UserName="[USERNAME]"

That's it.  You can access any built-in windows installer property or any property that you defined in any dialog.
    Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
        MyBase.Install(stateSaver)
        Dim SourceDir As String = Me.Context.Parameters.Item("SourceDir")
        Dim UserName As String = Me.Context.Parameters.Item("UserName")
        If SourceDir Is Nothing Then SourceDir = "SourceDir ERROR"
        If UserName Is Nothing Then UserName = "UserName ERROR"
        MsgBox(SourceDir, MsgBoxStyle.OkOnly, UserName)
    End Sub

Open in new window

Installer.GIF
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JeffvClaytonAuthor Commented:
Many thanks Bill, I had almost got there but I had'nt quite got the syntax for passing 2 parameters e.g. source and target, I had in error a ';' between the two just for luck!

Now all works fine.  I have also put my dll primary output unnder the Commit node as i wanted to make sure everything else was installed/folders set-up first.

Regards

Jeff

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.