locked
Could not find Installstate RRS feed

  • Question

  • User-244641733 posted

    hi friends,

    Many of us might have faced this problem while adding a batch file in the webserver.
    with some custom actions

    Custom action within installer - Could not find MyAction.Installstate

    I wanted to run custom action code during the Commit phase of the Setup Project.

    I created an installer class and override the Commit method. I also added that installer as a custom action to the Commit phase (View->Custom Actions).

    During the installation process I got an exception saying “Could not find C:\Program Files\MyApp\MyAction.Installstate”

    The problem is that the MSI infrastructure  is looking for the installation state file which is usually created during the Install phase. If the custom action does not participate in the Install phase, no file is created.

    The solution is to add the custom action to both the Install and the Commit phases, although it does nothing during the install phase.

    Thursday, July 21, 2005 6:58 PM

All replies

  • User-2097060974 posted

    Actually, the way I have my project set up, I use the Install phase and have no override for the Commit phase, so I do not believe that is accurate. 

    For each of the phases, in the Custom Actions section, I right-click and select Add > Add Custom Action... then select Application Folder in the dialog, then "Primary output from MyApp (Active)".

    For each of the phases, when I select "Primary output from MyApp (Active)", my InstallerClass property is True (I've seen other posts saying to change this to False - it is not necessary).

    For the Install phase, you select "Primary output from MyApp (Active)" and that is when you can set your CustomActionData string variables that you are gathering from dialog forms.  For me, I added Textboxes A and B forms in the User Interface section.  On A, I had one textbox, EDITA1.  It was for the path of a file, so the variable is "filepath".  On B, I had 2 boxes, EDITB1 and EDITB2.  These were assigned variables "host" and "port", as they were for some database information for my app to connect to upon installation.

    My CustomActionData string:

    /filepath="[EDITA1]" /host="[EDITB1]" /port="[EDITB2]"

    I ran into the error you did because I had left off a closing quote on one of the textboxes, with one error before it complaining it couldn't load a file or assembly from ///file:\C:\Windows\SYSWOW64\Files - without telling me what the file or assembly was.  Once I fixed the quote issue and re-built the Setup Project, it installed fine.

    So for the installer class, you really only need to override the Install method.  The rest will do what they would always do.  It is only during Install that you would grab the parameters and do something with them, for ex.:

    string filepath = Context.Parameters["filepath"];

    You don't have to do anything twice.

    Thursday, December 1, 2016 8:25 PM