Custom Actions problem in deployment

S

Steve Long

Hello,
I'm trying to get the installation folder that the user selects from my
setup program so I can write the value to the registry. I've written a
custom Installer that inherits from System.Configuration.Install.Installer
and overridden the Install and Uninstall methods. I'm trying to get the
install folder by using the this.Context.Parameters["INSTALLDIR"] (also
tried "TARGETDIR") and I get nothing back but TargetDir so that's what gets
written into the registry. Does anybody know a reliable way to get the
Install folder from the Context object? Or, am I going about this all wrong?

Code:

public override void Install(IDictionary stateSaver)
{
try
{
RegistryKey rKey = Registry.LocalMachine.OpenSubKey(SOFTWARE, true);
RegistryKey newKey = rKey.CreateSubKey(SUBKEY);
newKey.SetValue(IMAPPATH, this.Context.Parameters["TARGETDIR"]);
//IMAPPATH); //
stateSaver.Add(IMAPPATH, this.Context.Parameters["TARGETDIR"]);
newKey.Close();
rKey.Close();
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
base.Install (stateSaver);
}
 
S

Steve Long

Alright, in case anybody else has trouble with this, here's the deal.

I developed the Installer class and Inplemented the Install and Uninstall
methods of Installer. The code below is what is being used. The only trick
was to set the CustomActionData property of the CustomAction to:
/INSTALLDIR="[TARGETDIR]\"

Yes, there really is a back slash in there after TARGETDIR, and without it,
it doesn't work. I don't know why.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top