Installer Portion
My progress thus far is I have figured out how to utilize the Install component added to my CustomAction1 project, as well as the limitations associated with it only being callable after the install has installed everything designated in the setup. I understand why this is. I am able to retrieve setup parameters and pass in user-defined parameters from the setup--mission accomplished here.
My only remaining question in this area is whether anyone knows a technique for substituting a debugger instance of the CustomAction1 library at runtime of Setup so that breakpoint debugging can occur when setup calls the Install override? Although the capability is more of a luxury than a necessity at this point, for this portion at least, I am still curious to know.
I am reposting this portion of the code for anyone who happens along this thread because I know how difficult it is to find information on this subject that is correct and up-to-date; and, although my contribution is by no means a complete one, it does provide some insight to things I would have liked to have run into during the research. I am also attaching the current project for the same purpose.
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Runtime.InteropServices; // Deploying a .NET component customization
using System.Windows.Forms;
//using Microsoft.Deployment.WindowsInstaller; // creates a conflict with "Install" def
namespace CustomAction1
{
[RunInstaller(true)]
public partial class Installer1 : Installer
{
// Only method that gets generated when you add this class to the project as Install Component
public Installer1()
{
InitializeComponent();
MessageBox.Show("Install contsructor called...", "Debug"); // my debug message...
}
public override void Install(System.Collections.IDictionary stateSaver)
{
/* Below are messagebox's to indicate what's happening, when,
* and shows how to retrieve a parameter passed in from the setup.
*
* Most are useless once you know what is happening, but I left them in
* for the benefit of anybody else trying this stuff out for the first time.
*
* I could not find a way to work with breakpoints, but it might be possible to insert
* this instance or something at runtime while in the debugger.
*/
MessageBox.Show("Begin Install Override!\n\nNOTE: All files added to setup, if any, have already been installed!", "Debug");
// Let's see what parameters are passed in from setup:
string msg = "Parameters Passed In:\n\n";
foreach (string key in Context.Parameters.Keys)
{
string s = Context.Parameters[key];
msg += "\t" + key + "=" + s + "\n";
}
MessageBox.Show(msg, "Debug");
// MESSAGE parameter:
//
// This parameter is user-defined in Custom Action Properties's CustomActionData
// under the Install category item
// as: /Message="[MESSAGE]"
//
// It is set from the TextBoxes (A) generic dialog added to the User Interface View
// under the Start category following the default Welcome dialog added when the
// project is created.
msg = Context.Parameters["MESSAGE"];
MessageBox.Show("Message From Setup entered from TextBoxes (A), in Edit1Value Textbox:\n\n" + msg, "Debug");
// change the value of the CustomActionData parameter for MESSAGE just for hell of it
Context.Parameters["MESSAGE"] = "New Message Text, but can it be used by Setup at this point?";// -- save for future ref
// How do you get access to the Session's handle?
//Microsoft.Deployment.WindowsInstaller.Session session = Microsoft.Deployment.WindowsInstaller.Session.FromHandle(this., false);
// This remaining code is original method body that I copied off the web somewhere...
base.Install(stateSaver);
MessageBox.Show("Return from Install base.Install", "Debug"); // except for this debug statement.
RegistrationServices regSrv = new RegistrationServices();
regSrv.RegisterAssembly(base.GetType().Assembly,
AssemblyRegistrationFlags.SetCodeBase);
}
public override void Uninstall(System.Collections.IDictionary savedState)
{
MessageBox.Show("Begin Uninstall Override!", "Debug");
base.Uninstall(savedState);
RegistrationServices regSrv = new RegistrationServices();
regSrv.UnregisterAssembly(base.GetType().Assembly);
}
}
}
[CustomAction] Portion
I still would like to know how I can invoke the [CustomAction] I referred to when starting this thread, especially when user presses the next button on one of the setup dialogs and before the actual install starts. If anyone has an idea, I would really appreciate suggestions.
[CustomAction]
public static ActionResult CustomAction1(Session session)
Comments:
After refamiliarizing myself with setup, it occurs to me that this is not an ideal forum for these types of questions, but a reasonable alternative forum does not appear to present itself on this website either I don't think. If anyone knows of a website pertaining to this subject that is free and has a good amount of traffic with dedicated followers, please tell. Also, special thanks to anyone who has and will take the time to look at any of this thread because it is probably an area that most programmers are not interested in.