From e94cfe87c1db132a43fd79bdb02eb7be488c8e31 Mon Sep 17 00:00:00 2001 From: Feodor Date: Mon, 3 Sep 2012 15:35:47 -0700 Subject: [PATCH] WSP Installer checks updated for IIS 8, Windows 2012 and ASP.NET 4.0 --- .../Sources/WebsitePanel.Installer/App.config | 2 +- .../Sources/WebsitePanel.Setup/Common/OS.cs | 33 ++++++++++--- .../WebsitePanel.Setup/Common/Utils.cs | 12 +---- .../Wizard/ConfigurationCheckPage.cs | 49 ++++++++++--------- 4 files changed, 56 insertions(+), 40 deletions(-) diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Installer/App.config b/WebsitePanel.Installer/Sources/WebsitePanel.Installer/App.config index 60bc4b39..18e7f2ee 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Installer/App.config +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Installer/App.config @@ -9,7 +9,7 @@ - + diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs index 2284c66f..765781cf 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs @@ -282,7 +282,11 @@ namespace WebsitePanel.Setup WindowsXP, WindowsServer2003, WindowsVista, - WindowsServer2008 + WindowsServer2008, + Windows7, + WindowsServer2008R2, + Windows8, + WindowsServer2012 } public static string GetName(WindowsVersion version) @@ -404,11 +408,28 @@ namespace WebsitePanel.Setup } break; case 6: - if (info.wProductType == (byte)WinPlatform.VER_NT_WORKSTATION) - ret = WindowsVersion.WindowsVista; - else - ret = WindowsVersion.WindowsServer2008; - break; + switch (osInfo.Version.Minor) + { + case 0: + if (info.wProductType == (byte)WinPlatform.VER_NT_WORKSTATION) + ret = WindowsVersion.WindowsVista; + else + ret = WindowsVersion.WindowsServer2008; + break; + case 1: + if (info.wProductType == (byte)WinPlatform.VER_NT_WORKSTATION) + ret = WindowsVersion.Windows7; + else + ret = WindowsVersion.WindowsServer2008R2; + break; + case 2: + if (info.wProductType == (byte)WinPlatform.VER_NT_WORKSTATION) + ret = WindowsVersion.Windows8; + else + ret = WindowsVersion.WindowsServer2012; + break; + } + break; } break; } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs index 3bc41dba..5d00203b 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs @@ -590,16 +590,8 @@ namespace WebsitePanel.Setup public static bool CheckAspNet40Registered(SetupVariables setupVariables) { - // - var aspNet40Registered = false; - // Run ASP.NET Registration Tool command - var psOutput = ExecAspNetRegistrationToolCommand(setupVariables, "-lv"); - // Split process output per lines - var strLines = psOutput.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); - // Lookup for an evidence of ASP.NET 4.0 - aspNet40Registered = strLines.Any((string s) => { return s.Contains("4.0.30319.0"); }); - // - return aspNet40Registered; + var regkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\ASP.NET\\4.0.30319.0"); + return (regkey != null); } public static string ExecAspNetRegistrationToolCommand(SetupVariables setupVariables, string arguments) diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs index 7cb94dc0..6f49d5b7 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs @@ -40,6 +40,7 @@ using WebsitePanel.Setup.Web; using System.IO; using System.Management; using WebsitePanel.Setup.Actions; +using Microsoft.Win32; namespace WebsitePanel.Setup { @@ -233,9 +234,14 @@ namespace WebsitePanel.Setup Log.WriteInfo(string.Format("OS check: {0}", details)); if (!(version == OS.WindowsVersion.WindowsServer2003 || - version == OS.WindowsVersion.WindowsServer2008)) + version == OS.WindowsVersion.WindowsServer2008 || + version == OS.WindowsVersion.WindowsServer2008R2 || + version == OS.WindowsVersion.WindowsServer2012 || + version == OS.WindowsVersion.WindowsVista || + version == OS.WindowsVersion.Windows7 || + version == OS.WindowsVersion.Windows8 )) { - details = "Windows Server 2003 or Windows Server 2008 required."; + details = "OS required: Windows Server 2008/2008 R2/2012 or Windows Vista/7/8."; Log.WriteError(string.Format("OS check: {0}", details), null); #if DEBUG return CheckStatuses.Warning; @@ -318,12 +324,12 @@ namespace WebsitePanel.Setup Log.WriteInfo(string.Format("ASP.NET check: {0}", details)); return CheckStatuses.Error; } - if (!IsAspNetRoleServiceInstalled()) - { - details = "ASP.NET role service is not installed on your server. Run Server Manager to add ASP.NET role service."; - Log.WriteInfo(string.Format("ASP.NET check: {0}", details)); - return CheckStatuses.Error; - } + if (!IsAspNetRoleServiceInstalled()) + { + details = "ASP.NET role service is not installed on your server. Run Server Manager to add ASP.NET role service."; + Log.WriteInfo(string.Format("ASP.NET check: {0}", details)); + return CheckStatuses.Error; + } // Register ASP.NET 4.0 if (Utils.CheckAspNet40Registered(SetupVariables) == false) { @@ -584,25 +590,22 @@ namespace WebsitePanel.Setup private static bool IsWebServerRoleInstalled() { - WmiHelper wmi = new WmiHelper("root\\cimv2"); - using (ManagementObjectCollection roles = wmi.ExecuteQuery("SELECT NAME FROM Win32_ServerFeature WHERE ID=2")) - { - return (roles.Count > 0); - } + RegistryKey regkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\InetStp"); + if (regkey == null) + return false; + + int value = (int)regkey.GetValue("MajorVersion", 0); + return value == 7 || value == 8; } private static bool IsAspNetRoleServiceInstalled() { - WmiHelper wmi = new WmiHelper("root\\cimv2"); - using (ManagementObjectCollection roles = wmi.ExecuteQuery("SELECT NAME FROM Win32_ServerFeature WHERE ID=148")) - { - return (roles.Count > 0); - } + RegistryKey regkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\InetStp\\Components"); + if (regkey == null) + return false; + + int value = (int)regkey.GetValue("ASPNET", 0); + return value == 1; } - - - - - } }