locked
Writing Custom Actions in Visual Studio 2005 RRS feed

  • Question

  • I am trying to write a custom action to a setup project for an application I'm writing.  This custom action is based on the input received from an addional 4 button radio button dialog box I added to the setup project thru visual studio 2005. 

     

    Basically, this additional dialog allows the user to select one of 4 machines he could be installing the software on and based on this selection I want to copy a custom config to the current config file for the application.  Each machine has a separate config file for different settings based on that particular machine.

     

    I have written the custom action and it fires successfully.  However, I can not find in any documentation anywhere on how to reference the radio button property I added in the additional dialog box in the setup project.  Can someone please point me in right direction or provide an example of how to do this?

     

    Mark

    Monday, February 4, 2008 7:24 PM

Answers

  • In CustomActionData in the custom action, you'd put /button=[BUTTON2] and then in the installer class, Context.Parameters["button"] would contain the resolved value, 1 or 2.

    Tuesday, February 5, 2008 9:04 PM

All replies

  • Look at the name of the property in the properties window for that UI dialog. Example: the two radiobutton dialog has a property (case-sensitive) called BUTTON2. This ends up with a value of 1 or 2 depending which button was selected. In your custom action you just need to put [BUTTON2] in your CustomActionData, the details of how you do that depending on what kind of custom action call you have.

     

    Monday, February 4, 2008 9:06 PM
  • Cool, Thanks!

     

    Next question is how do I reference this in my Installer class?  It would be great if you could give me an example in code?

     

    Thanks, again!

    Mark

    Monday, February 4, 2008 9:33 PM
  • In CustomActionData in the custom action, you'd put /button=[BUTTON2] and then in the installer class, Context.Parameters["button"] would contain the resolved value, 1 or 2.

    Tuesday, February 5, 2008 9:04 PM
  • What's really starting to annoy me is that I have followed all of the steps and yet my installer is not working. No matter what the value selected (I have tried two different radio button dialogs and the edit control dialog) it tells me that the value is 1. I just don't get it. The most confusing part is when it says that the contents of the edit control is 1!

     

    Any ideas?

    Wednesday, February 20, 2008 11:39 AM
  • I assume you're using the UI dialog with 4 radiobuttons, When you say it tells you that the value is 1, how are you getting the value?  Please post your CustomActionData string. Let's stick to the radiobuttons dialog.

    Wednesday, February 20, 2008 4:27 PM
  • I am "trying" to use the dialog with four radio buttons.

     

    In the CustomActionData property for my Custom Action in the installer, I have set the following:

     

    /env=[ENV]

     

    ENV is the name I have given to the ButtonProperty on the dialog with the radio buttons.

     

    In my Installer class I have the following code to iterate through all of the parameters passed to it.

     

    StringBuilder sb = new StringBuilder();

    StringDictionary myStringDictionary = this.Context.Parameters;

    sb.Append("From " + "INSTALL" + "\n");

    if (this.Context.Parameters.Count > 0)

    {

    foreach (string myString in this.Context.Parameters.Keys)

    {

    sb.AppendFormat("String={0} Value= {1}\n", myString, this.Context.Parameters[myString]);

    }

    }

    MessageBox.Show(sb.ToString());

     

    This then shows in the message box "String= env Value=1"

     

    It's rather odd

    Thursday, February 21, 2008 4:17 PM