Installation

Equinox84 Messages postés 63 Date d'inscription lundi 2 février 2004 Statut Membre Dernière intervention 19 mai 2010 - 27 nov. 2007 à 10:56
cs_khelifaoui Messages postés 35 Date d'inscription dimanche 5 novembre 2006 Statut Membre Dernière intervention 1 décembre 2007 - 1 déc. 2007 à 10:18
Bonjour tout le monde,

Dans ma solution , j'ai crée des projets de fusions, un projet d'installation et un projet pour mon Installer qui a l'unique classe que voici

namespace InstallerLibrary
{
  public class InstallState : System.Configuration.Install.Installer
  {
    public override void Commit(IDictionary savedState)
    {
      try
      {
        File.WriteAllText("c:\\test.txt","avant");

        string installFolder = Context.Parameters["assemblypath"];

        File.WriteAllText("c:\\test.txt",Path.GetFullPath(installFolder));

        installFolder = Path.GetFullPath(installFolder);

        RegistryKey key = Registry.LocalMachine;

        RegistryKey configKey = key.OpenSubKey("Software\\SRCI\\AS2");

        if (configKey == null)
        {
          key.CreateSubKey("Software\\SRCI\\AS2");
          configKey = key.OpenSubKey("Software\\SRCI\\AS2", true);
          configKey.SetValue("InstallFolder", installFolder);
          configKey.SetValue("PartnersFolder", Path.Combine(installFolder, "Partenaires"));
          configKey.SetValue("DatabasePath", Path.Combine(installFolder, "as2.mdb"));
        }
        else
        {
          configKey = key.OpenSubKey("Software\\SRCI\\AS2", true);
          configKey.SetValue("InstallFolder", installFolder);
          configKey.SetValue("PartnersFolder", Path.Combine(installFolder, "Partenaires"));
          configKey.SetValue("DatabasePath", Path.Combine(installFolder, "as2.mdb"));
        }

        key.Close();
        configKey.Close();

        Directory.CreateDirectory(Path.Combine(installFolder, "Partenaires"));
      }
      catch (Exception ex)
      {
        throw new InstallException("Erreur de modification de la base de registre " + ex.Message);
      }
    }

    public override void Uninstall(IDictionary savedState)
    {
      base.Uninstall(savedState);

      try
      {
        RegistryKey key = Registry.LocalMachine;
        RegistryKey configKey = key.OpenSubKey("Software\\SRCI\\AS2");

        if (configKey != null)
          key.DeleteSubKeyTree("Software\\SRCI\\AS2");

        key.Close();
      }
      catch (Exception ex)
      {
        throw new InstallException("Erreur de modification de la base de registre " + ex.Message);
      }
    }
  }
}

Mes méthodes ne sont jamais appelées, est ce que je dois référencer mon projet qui posséde cette classe dans un installer ou un projet de fusion ?

Merci

1 réponse

cs_khelifaoui Messages postés 35 Date d'inscription dimanche 5 novembre 2006 Statut Membre Dernière intervention 1 décembre 2007
1 déc. 2007 à 10:18
il faut réecrivez le code dans un fichier installer.cs;
0
Rejoignez-nous