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); } }
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); } }
/// <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); }
public void Execute(ExecutingOptions options) { var installer = new ProjectInstaller { DisplayName = options.Name, Description = options.Name, Context = new InstallContext() }; installer.Uninstall(null); }
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); }
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); } }
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); }
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(); }