Inheritance: MonoInstaller
Exemplo n.º 1
0
        public void Execute(ExecutingOptions options)
        {
            var installer = new ProjectInstaller
            {
                DisplayName = options.Name,
                Description = options.Name,
                Context = new InstallContext()
            };

            installer.Context.Parameters.Add("assemblypath", GetType().Assembly.Location);

            installer.Install(new Hashtable());

            using (var system = Registry.LocalMachine.OpenSubKey("System"))
            using (var currentControlSet = system.OpenSubKey("CurrentControlSet"))
            using (var services = currentControlSet.OpenSubKey("Services"))
            using (var service = services.OpenSubKey(installer.ServiceName, true))
            {
                var path = (string)service.GetValue("ImagePath");

                options.Action = Action.Server;

                service.SetValue("ImagePath", path + options);
            }
        }
Exemplo n.º 2
0
        public void Execute(ExecutingOptions options)
        {
            var installer = new ProjectInstaller
            {
                DisplayName = options.Name,
                Description = options.Name,
                Context     = new InstallContext()
            };

            installer.Context.Parameters.Add("assemblypath", GetType().Assembly.Location);

            installer.Install(new Hashtable());

            using (var system = Registry.LocalMachine.OpenSubKey("System"))
                using (var currentControlSet = system.OpenSubKey("CurrentControlSet"))
                    using (var services = currentControlSet.OpenSubKey("Services"))
                        using (var service = services.OpenSubKey(installer.ServiceName, true))
                        {
                            var path = (string)service.GetValue("ImagePath");

                            options.Action = Action.Server;

                            service.SetValue("ImagePath", path + options);
                        }
        }
Exemplo n.º 3
0
        public void Execute(ExecutingOptions options)
        {
            var installer = new ProjectInstaller
            {
                DisplayName = options.Name,
                Description = options.Name,
                Context = new InstallContext()
            };

            if (!string.IsNullOrEmpty(options.Account))
            {
                if (string.IsNullOrEmpty(options.Password))
                {
                    throw new InvalidOperationException("When /Action is Install and /Account is set /Password is required.");
                }

                installer.SetUserAccount(options.Account, options.Password);
            }

            installer.Context.Parameters.Add("assemblypath", GetType().Assembly.Location);

            installer.Install(new Hashtable());

            using (var system = Registry.LocalMachine.OpenSubKey("System"))
            using (var currentControlSet = system.OpenSubKey("CurrentControlSet"))
            using (var services = currentControlSet.OpenSubKey("Services"))
            using (var service = services.OpenSubKey(installer.ServiceName, true))
            {
                var path = (string)service.GetValue("ImagePath");

                options.Action = Action.Server;

                service.SetValue("ImagePath", path + options);
            }
        }
Exemplo n.º 4
0
        public void Execute(ExecutingOptions options)
        {
            var installer = new ProjectInstaller
            {
                DisplayName = options.Name,
                Description = options.Name,
                Context     = new InstallContext()
            };

            if (!string.IsNullOrEmpty(options.Account))
            {
                if (string.IsNullOrEmpty(options.Password))
                {
                    throw new InvalidOperationException("When /Action is Install and /Account is set /Password is required.");
                }

                installer.SetUserAccount(options.Account, options.Password);
            }

            installer.Context.Parameters.Add("assemblypath", GetType().Assembly.Location);

            installer.Install(new Hashtable());

            using (var system = Registry.LocalMachine.OpenSubKey("System"))
                using (var currentControlSet = system.OpenSubKey("CurrentControlSet"))
                    using (var services = currentControlSet.OpenSubKey("Services"))
                        using (var service = services.OpenSubKey(installer.ServiceName, true))
                        {
                            var path = (string)service.GetValue("ImagePath");

                            options.Action = Action.Server;

                            service.SetValue("ImagePath", path + options);
                        }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Executes the specified options.
 /// </summary>
 /// <param name="options">The options.</param>
 public void Execute(ExecutingOptions options)
 {
     var installer = new ProjectInstaller
     {
         DisplayName = options.Name,
         Description = options.Name,
         Context = new InstallContext()
     };
     installer.Uninstall(null);
 }
Exemplo n.º 6
0
        public void Execute(ExecutingOptions options)
        {
            var installer = new ProjectInstaller
            {
                DisplayName = options.Name,
                Description = options.Name,
                Context     = new InstallContext()
            };

            installer.Uninstall(null);
        }
Exemplo n.º 7
0
        static void Main( string[] args )
        {
            InstallContext context = new InstallContext();

            context.Parameters["assemblypath"] = typeof( ProjectInstaller ).Assembly.CodeBase.Substring( 8 ).Replace( '/', '\\' );
            context.Parameters["Mode"] = "1";

            using (ProjectInstaller installer = new ProjectInstaller { AutoTestMode = true, Context = context })
            {
                Dictionary<string, string> items = new Dictionary<string, string>();

                installer.Install( items );
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="serviceDisplayName">null for using the assembly name.</param>
        /// <param name="serviceName">null for using the assembly name.</param>
        public EasyService(string serviceDisplayName = null, string serviceName = null)
        {
            var assemblyName = Assembly.GetEntryAssembly().GetName().Name;

            _serviceDisplayName = serviceDisplayName ?? assemblyName;
            serviceName         = serviceName ?? assemblyName;

            _serviceManager      = new WindowsServiceManager(_serviceDisplayName);
            _registryManipulator = new RegistryManipulator(serviceName);

            InternalService.OsStarted += Start;
            InternalService.OsStopped += Stop;
            ProjectInstaller.InitInstaller(_serviceDisplayName, serviceName);
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            InstallContext context = new InstallContext();

            context.Parameters["assemblypath"] = typeof(ProjectInstaller).Assembly.CodeBase.Substring(8).Replace('/', '\\');
            context.Parameters["Mode"]         = "1";

            using (ProjectInstaller installer = new ProjectInstaller {
                AutoTestMode = true, Context = context
            })
            {
                Dictionary <string, string> items = new Dictionary <string, string>();

                installer.Install(items);
            }
        }
Exemplo n.º 10
0
        public MicroService(int port = 8081, string serviceDisplayName = null, string serviceName = null,
                            Action <HttpConfiguration> configure = null, bool useCors = true)
        {
            _port      = port;
            _configure = configure;
            _useCors   = useCors;

            var assemblyName = Assembly.GetEntryAssembly().GetName().Name;

            _serviceDisplayName = serviceDisplayName ?? assemblyName;
            serviceName         = serviceName ?? assemblyName;

            _serviceManager      = new WindowsServiceManager(_serviceDisplayName);
            _registryManipulator = new RegistryManipulator(serviceName);

            InternalService.OsStarted += () => Start(_configure, _useCors);
            InternalService.OsStopped += Stop;
            ProjectInstaller.InitInstaller(_serviceDisplayName, serviceName);
        }
Exemplo n.º 11
0
        private void InitMicroService(string ipAddress, int port, string serviceDisplayName, string serviceName,
                                      Action <HttpConfiguration> configure, bool useCors)
        {
            _ipAddress = ipAddress;
            _port      = port;
            _configure = configure;
            _useCors   = useCors;

            var assemblyName = Assembly.GetEntryAssembly().GetName().Name;

            _serviceDisplayName = serviceDisplayName ?? assemblyName;
            serviceName         = serviceName ?? assemblyName;

            _serviceManager      = new WindowsServiceManager(_serviceDisplayName);
            _registryManipulator = new RegistryManipulator(serviceName);

            InternalService.OsStarted += () => Start(_configure, _useCors);
            InternalService.OsStopped += Stop;
            ProjectInstaller.InitInstaller(_serviceDisplayName, serviceName);
        }
 public void ProjectInstallerSucceeds()
 {
     var sut = new ProjectInstaller();
 }