public void Configure(string appPoolName, Action <ApplicationPool> configureAction) { if (!TryFind(appPoolName, out var appPool)) { handle.Server.ApplicationPools.Add(appPoolName); handle.CommitChanges(); if (!TryFind(appPoolName, out appPool)) { handle.Context.Output.WriteBlock() .Write("Unable to create Application Pool ", ConsoleColor.DarkRed) .Write(appPoolName, ConsoleColor.Red) .WriteLine("!", ConsoleColor.DarkRed) .Post(); throw new Exception($"Unable to create Application Pool '{appPoolName}'!"); } handle.Context.Output.WriteBlock() .Write("Created new Application Pool ", ConsoleColor.DarkBlue) .Write(appPoolName, ConsoleColor.Blue) .WriteLine(".", ConsoleColor.DarkBlue) .Post(); } configureAction(appPool); handle.CommitChanges(); handle.Context.Output.WriteBlock() .Write("Application Pool ", ConsoleColor.DarkGreen) .Write(appPoolName, ConsoleColor.Green) .WriteLine(" configured successfully.", ConsoleColor.DarkGreen) .Post(); }
public void Configure(string webSiteName, string webAppPath, Action <Application> configureAction) { if (!TryFindWebSite(webSiteName, out var webSite)) { using (var block = handle.Context.Output.WriteBlock()) { block.Write("WebSite ", ConsoleColor.DarkRed); block.Write(webSiteName, ConsoleColor.Red); block.WriteLine(" was not found!", ConsoleColor.DarkRed); } throw new Exception($"WebSite '{webSiteName}' was not found!"); } if (!TryFind(webSite, webAppPath, out var webApp)) { webSite.Applications.Add(webAppPath, DefaultPhysicalPath); handle.CommitChanges(); if (!TryFindWebSite(webSiteName, out webSite)) { using (var block = handle.Context.Output.WriteBlock()) { block.Write("WebSite ", ConsoleColor.DarkRed); block.Write(webSiteName, ConsoleColor.Red); block.WriteLine(" was not found!", ConsoleColor.DarkRed); } throw new Exception($"WebSite '{webSiteName}' was not found!"); } if (!TryFind(webSite, webAppPath, out webApp)) { using (var block = handle.Context.Output.WriteBlock()) { block.Write("Unable to create Web Application ", ConsoleColor.DarkRed); block.Write(webSiteName, ConsoleColor.Red); block.WriteLine("!", ConsoleColor.DarkRed); } throw new Exception($"Unable to create Web Application '{webSiteName}'!"); } using (var block = handle.Context.Output.WriteBlock()) { block.Write("Created new Web Application ", ConsoleColor.DarkBlue); block.Write(webAppPath, ConsoleColor.Blue); block.Write(" under WebSite ", ConsoleColor.DarkBlue); block.Write(webSiteName, ConsoleColor.Blue); block.WriteLine(".", ConsoleColor.DarkBlue); } } configureAction(webApp); handle.CommitChanges(); using (var block = handle.Context.Output.WriteBlock()) { block.Write("Web Application ", ConsoleColor.DarkGreen); block.Write(webSiteName, ConsoleColor.Green); block.WriteLine(" configured successfully.", ConsoleColor.DarkGreen); } }
public void Configure(string websiteName, int port, Action <Site> configureAction) { if (!TryFind(websiteName, out var webSite)) { handle.Context.WriteTagLine($"Creating IIS WebSite '{websiteName}'...", ConsoleColor.White); try { handle.Server.Sites.Add(websiteName, DefaultPhysicalPath, port); handle.CommitChanges(); } catch (Exception error) { handle.Context.WriteErrorBlock($"Failed to create IIS WebSite '{websiteName}'!", error.UnfoldMessages()); throw; } if (!TryFind(websiteName, out webSite)) { handle.Context.WriteErrorBlock($"Failed to create IIS WebSite '{websiteName}'!"); throw new Exception($"Failed to create IIS WebSite '{websiteName}'!"); } handle.Context.WriteActionBlock($"Created new IIS WebSite '{websiteName}' successfully."); } try { handle.Context.WriteTagLine($"Configuring IIS WebSite '{websiteName}'...", ConsoleColor.White); // TODO: Set Port //webSite.Bindings.FirstOrDefault()?.po configureAction(webSite); handle.CommitChanges(); handle.Context.WriteTagLine($"Configured IIS WebSite '{websiteName}' successfully.", ConsoleColor.White); } catch (Exception error) { handle.Context.WriteErrorBlock($"Failed to configure IIS WebSite '{websiteName}'!", error.UnfoldMessages()); throw; } }
public void Configure(string appPoolName, Action <ApplicationPool> configureAction) { if (!TryFind(appPoolName, out var appPool)) { handle.Context.WriteTagLine($"Creating IIS Application Pool '{appPoolName}'...", ConsoleColor.White); try { handle.Server.ApplicationPools.Add(appPoolName); handle.CommitChanges(); } catch (Exception error) { handle.Context.WriteErrorBlock($"Failed to create IIS Application Pool '{appPoolName}'!", error.UnfoldMessages()); throw; } if (!TryFind(appPoolName, out appPool)) { handle.Context.WriteErrorBlock($"Failed to create IIS Application Pool '{appPoolName}'!"); throw new Exception($"Unable to create IIS Application Pool '{appPoolName}'!"); } handle.Context.WriteTagLine($"Created IIS Application Pool '{appPoolName}' successfully.", ConsoleColor.White); } try { handle.Context.WriteTagLine($"Configuring IIS Application Pool '{appPoolName}'...", ConsoleColor.White); configureAction(appPool); handle.CommitChanges(); handle.Context.WriteTagLine($"Configured IIS Application Pool '{appPoolName}'.", ConsoleColor.White); } catch (Exception error) { handle.Context.WriteErrorBlock($"Failed to configure IIS Application Pool '{appPoolName}'!", error.UnfoldMessages()); throw; } }
public void Configure(string websiteName, int port, Action <Site> configureAction) { if (!TryFind(websiteName, out var webSite)) { handle.Server.Sites.Add(websiteName, DefaultPhysicalPath, port); handle.CommitChanges(); if (!TryFind(websiteName, out webSite)) { handle.Context.Output.WriteBlock() .Write("Unable to create WebSite ", ConsoleColor.DarkRed) .Write(websiteName, ConsoleColor.Red) .WriteLine("!", ConsoleColor.DarkRed) .Post(); throw new Exception($"Unable to create WebSite '{websiteName}'!"); } handle.Context.Output.WriteBlock() .Write("Created new WebSite ", ConsoleColor.DarkBlue) .Write(websiteName, ConsoleColor.Blue) .WriteLine(".", ConsoleColor.DarkBlue) .Post(); } // TODO: Set Port //webSite.Bindings.FirstOrDefault()?.po configureAction(webSite); handle.CommitChanges(); handle.Context.Output.WriteBlock() .Write("WebSite ", ConsoleColor.DarkGreen) .Write(websiteName, ConsoleColor.Green) .WriteLine(" configured successfully.", ConsoleColor.DarkGreen) .Post(); }