Installer runs every time

dakota97

Centurion
Joined
Nov 14, 2003
Messages
116
Location
Pennsylvania
Hi all,

It's been a while since I've posted here, but I haven't forgotten all of you, and I'm back with another strange issue.

I'm using VS2008 and I've created a standard deployment project for my app. I've created a custom installer class to override the standard one simply to delete a configuration file based on the user's selection during the install. This way I can have one package to deploy both version of the program, and the user selection determines which version is installed. Simple enough right?

The problem is that each time the application is started, the Windows Installer appears and "re-installs" the application. This in turn puts both configuration files back in the application directory. It appears that my customer installer is run during this process, but since there is no selection, it doesn't delete either of the 2 files.

So, in short, why is the installer running each time the application is started? Any ideas would be greatly appreciated. My code for the custom installer is as follows:

Code:
public override void Install(IDictionary stateSaver)
        {
            string installedVersion = Context.Parameters["Selection"];
            string installDirectory = Path.GetDirectoryName(Context.Parameters["assemblypath"]);

            //Delete the appropriate configuration file
            if (installedVersion == "Standard")
            {
                if (File.Exists(installDirectory + "\\Configuration.xml"))
                    File.Delete(installDirectory + "\\Configuration.xml");
            }
            else if (installedVersion == "Network")
            {
                if (File.Exists(installDirectory + "\\Config.xml"))
                    File.Delete(installDirectory + "\\Config.xml");
            }
        }

Thanks in advance,

-Chris
 
The only thing that springs to mind is that both files could be marked as being essential to the deployment (I can't remember the exact term - essential or vital or required kind of thing springs to mind).

If a required file is missing the installer will attempt to repair the application on launch.
 
As always you've come through again. I went into the file system viewer and set the properties of the configuration files to "Vital = false" and the installer no longer runs each time.

Once again, thank you.

-Chris
 
Back
Top