예제 #1
0
        /// <summary>
        /// 获取当前的安装信息
        /// </summary>
        /// <returns></returns>
        private TransactedInstaller GetTransactedInstaller()
        {
            TransactedInstaller installer = new TransactedInstaller();

            installer.BeforeInstall   += new InstallEventHandler((obj, state) => { Console.WriteLine("服务正在安装......"); });
            installer.AfterInstall    += new InstallEventHandler((obj, state) => { Console.WriteLine("服务安装完成!"); });
            installer.BeforeUninstall += new InstallEventHandler((obj, state) => { Console.WriteLine("服务正在卸载......"); });
            installer.AfterUninstall  += new InstallEventHandler((obj, state) => { Console.WriteLine("服务卸载完成!"); });

            BusinessInstaller businessInstaller = new BusinessInstaller(InstallerConfig);

            installer.Installers.Add(businessInstaller);
            string logFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "installer.log");
            string path    = string.Format("/assemblypath={0}", System.Reflection.Assembly.GetExecutingAssembly().Location);

            string[]       cmd     = { path };
            InstallContext context = new InstallContext(logFile, cmd);

            installer.Context = context;

            return(installer);
        }
        /// <summary>
        /// 获取当前的安装信息
        /// </summary>
        /// <returns></returns>
        private TransactedInstaller GetTransactedInstaller()
        {
            TransactedInstaller installer = new TransactedInstaller();
            installer.BeforeInstall += new InstallEventHandler((obj, state) => { Console.WriteLine("服务正在安装......"); });
            installer.AfterInstall += new InstallEventHandler((obj, state) => { Console.WriteLine("服务安装完成!"); });
            installer.BeforeUninstall += new InstallEventHandler((obj, state) => { Console.WriteLine("服务正在卸载......"); });
            installer.AfterUninstall += new InstallEventHandler((obj, state) => { Console.WriteLine("服务卸载完成!"); });

            BusinessInstaller businessInstaller = new BusinessInstaller(InstallerConfig);
            installer.Installers.Add(businessInstaller);
            string logFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "installer.log");
            string path = string.Format("/assemblypath={0}", System.Reflection.Assembly.GetExecutingAssembly().Location);
            string[] cmd = { path };
            InstallContext context = new InstallContext(logFile, cmd);
            installer.Context = context;

            return installer;
        }