tags:

views:

734

answers:

2

I have a setup project with a custom installer class which launch the application at the end of the installation. In the setup, I create a shortcut to the output of the application. The installation goes fine. But when I click on the shortcut, the installer restart and the application launch at the same time? Why?

No, the code of my custom class is:

/// <summary>
/// Installer class to automatically launch the application at  the end of the installation/
/// </summary>
[RunInstaller(true)]
public partial class InstallerStartApplication : Installer
{
    /// <summary>
    /// Initializes a new instance of the <see cref="InstallerStartApplication"/> class.
    /// </summary>
    public InstallerStartApplication()
    {            
        InitializeComponent();            
    }

    /// <summary>
    /// Raises the <see cref="E:System.Configuration.Install.Installer.AfterInstall"/> event.
    /// </summary>
    /// <param name="savedState">An <see cref="T:System.Collections.IDictionary"/> that contains the state of the computer after all the installers contained in the <see cref="P:System.Configuration.Install.Installer.Installers"/> property have completed their installations.</param>
    protected override void OnAfterInstall(IDictionary savedState)
    {
        base.OnAfterInstall(savedState);


    }

    // Override the 'Install' method.
    public override void Install(IDictionary savedState)
    {
        base.Install(savedState);
    }

    // Override the 'Commit' method.
    public override void Commit(IDictionary savedState)
    {           
        base.Commit(savedState);

        try
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            Process.Start(Path.Combine(Directory.GetCurrentDirectory(), "IERssNotificator.exe"), "-c");
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex);
        }  
    }

    // Override the 'Rollback' method.
    public override void Rollback(IDictionary savedState)
    {
        base.Rollback(savedState);
    }


}

I launch this at install and commit custom action.

+1  A: 

The setup project places special type of shortcut. It does not simply launch you program. It first checks that all files installed with the program are present. If they do, it launches the program, if they don't installer is run again from msi cache to reinstall missing files.

Do you have post-install actions that delete some of the installed files?

Alex Reitbort
No, see my code... Above
Coolweb
Is there any way to have it create a *normal* shortcut instead of the sort that triggers an installer?
Dan Neely
I did not find it. At the end, I created shortcut in the Commit action using WinAPI. You can use WScript.Shell or http://www.msjogren.net/dotnet/eng/samples/dotnet_shelllink.asp library
Alex Reitbort
ok, but in my case I don't understand why the installation restart...
Coolweb
I have remove all of my custom actions, launch condition, the only thing which still exist is a creation of a reg key. And the setup relaunch when I click on the shortcut... I don't understand.
Coolweb
A: 

ok, I found the problem. The error is in the code of the custom installer class:

Process.Start(Path.Combine(Directory.GetCurrentDirectory(), "IERssNotificator.exe"), "-c");

This launch a process, not asynchronous and the setup never end. It is why it always restart the setup.

I change my code and laucn the process into a separate thread and so the setup complete.

Coolweb