views:

53

answers:

1

im deploying an application and during the installation after the user choose where to install the app i want to get that path , im in a custom action already but i dont know how to get the application path where its going to be installed !

its Windows Forms and im developing using Visual studio 2010 "C#".

and im using the default deploying tool...

any idea ?

thanks in advance...

+1  A: 

The class your custom action is in should inherit from System.Configuration.Installer.Installer. This has a parameter on it called Context which has a Parameters dictionary. The dictionary contains a number of useful variables about the install and you can add some.

Once you have added the custom installer to your install project in the Custom Actions pain. Select the Install action and set the CustomActionData property to:

/targetdir="[TARGETDIR]\"

Then you can access the path like this:

[RunInstaller(true)]
public partial class CustomInstaller : System.Configuration.Install.Installer
{
    public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);
        string path = this.Context.Parameters["targetdir"]; 
        // Do something with path.
    } 
}
Martin Brown
this doesnt work :(
Stacker
My bad. You also need to set the CustomActionData property. Post updated.
Martin Brown