diff --git a/WebsitePanel.Installer/Sources/Setup.SchedulerService/Setup.SchedulerService.wixproj b/WebsitePanel.Installer/Sources/Setup.SchedulerService/Setup.SchedulerService.wixproj index e067c9b7..4f0a70f4 100644 --- a/WebsitePanel.Installer/Sources/Setup.SchedulerService/Setup.SchedulerService.wixproj +++ b/WebsitePanel.Installer/Sources/Setup.SchedulerService/Setup.SchedulerService.wixproj @@ -3,7 +3,7 @@ Debug x86 - 3.7 + 3.9 {ead7c528-ea3d-40e8-9688-9f1d8dc8d758} 2.0 Websitepanel-SchedulerService @@ -49,4 +49,4 @@ --> - \ No newline at end of file + diff --git a/WebsitePanel.Installer/Sources/Setup.WIX/Setup.WIX.wixproj b/WebsitePanel.Installer/Sources/Setup.WIX/Setup.WIX.wixproj index d3178260..fa43aa7a 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIX/Setup.WIX.wixproj +++ b/WebsitePanel.Installer/Sources/Setup.WIX/Setup.WIX.wixproj @@ -3,7 +3,7 @@ Debug x86 - 3.7 + 3.9 f963a4af-cc72-4512-b636-829345c35318 2.0 WebsitePanelInstaller @@ -91,4 +91,4 @@ --> - \ No newline at end of file + diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller.CreateFileList.bat b/WebsitePanel.Installer/Sources/Setup.WIXInstaller.CreateFileList.bat index 1dfc0e52..441907d7 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIXInstaller.CreateFileList.bat +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller.CreateFileList.bat @@ -1,6 +1,8 @@ -"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\Release\EnterpriseServer -o Setup.WIXInstaller\EnterpriseServerFiles.wxs -gg -sreg -srd -var wix.BUILDESPATH -cg EnterpriseServerFiles -dr INSTALLENTERPRISESERVERFOLDER +"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\debug\EnterpriseServer -o Setup.WIXInstaller\EnterpriseServerFiles.wxs -gg -sreg -srd -var wix.BUILDESPATH -cg EnterpriseServerFiles -dr INSTALLENTERPRISESERVERFOLDER -"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\Release\Server -o Setup.WIXInstaller\ServerFiles.wxs -gg -sreg -srd -var wix.BUILDSPATH -cg ServerFiles -dr INSTALLSERVERFOLDER +"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\debug\Server -o Setup.WIXInstaller\ServerFiles.wxs -gg -sreg -srd -var wix.BUILDSPATH -cg ServerFiles -dr INSTALLSERVERFOLDER -"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\Release\Portal -o Setup.WIXInstaller\PortalFiles.wxs -gg -sreg -srd -var wix.BUILDPPATH -cg PortalFiles -dr INSTALLPORTALFOLDER +"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\debug\Portal -o Setup.WIXInstaller\PortalFiles.wxs -gg -sreg -srd -var wix.BUILDPPATH -cg PortalFiles -dr INSTALLPORTALFOLDER + +"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\debug\WebDavPortal -o Setup.WIXInstaller\WebDavPortalFiles.wxs -gg -sreg -srd -var wix.BUILDWDPPATH -cg WebDavPortalFiles -dr INSTALLWEBDAVPORTALFOLDER diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Config.wxi b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Config.wxi index dad6088c..3e009012 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Config.wxi +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Config.wxi @@ -1,5 +1,14 @@ - - + + + + + + + + + + + diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs index 0b827603..26442c52 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs @@ -1,421 +1,691 @@ - - - - - - - - - - - - - - - - - - - - - - - - bannrbmp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - AUTHENTICATIONTYPE = "Windows Authentication" - NOT(AUTHENTICATIONTYPE = "Windows Authentication") - - - - - - - - - - - 1 - - - &EnterpriseServerFeature=3 - &SchedulerServiceFeature=3 - &PortalFeature=3 - - - 1 - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - AUTHENTICATIONTYPE = "Windows Authentication" - NOT(AUTHENTICATIONTYPE = "Windows Authentication") - - - - - - - - - - - 1 - - - &EnterpriseServerFeature=3 - &SchedulerServiceFeature=3 - &PortalFeature=3 - - - 1 - - - - - - - - - - - - - - - - 1 - - - &PortalFeature=3 - 1 - - - 1 - - - - - - - - - - - - - - - - - - AUTHENTICATIONTYPE = "Windows Authentication" - NOT(AUTHENTICATIONTYPE = "Windows Authentication") - - - - - - - - - 1 - - - Connection not valid. - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - AUTHENTICATIONTYPE = "Windows Authentication" - NOT(AUTHENTICATIONTYPE = "Windows Authentication") - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - - - - 1 - - - - - - - - - - - LicenseAccepted = "1" - - - &ServerFeature=3 - &EnterpriseServerFeature=3 - &SchedulerServiceFeature=3 - &PortalFeature=3 - - 1 - - - - - - - (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") - - NOT Installed or REINSTALL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOT(PI_SERVER_CREATE_AD = "1") + PI_SERVER_CREATE_AD = "1" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOT(PI_ESERVER_CREATE_AD = "1") + PI_ESERVER_CREATE_AD = "1" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DB_CONN_CORRECT="0" + DB_CONN_CORRECT="1" + + + + + + + + + + + + + + + + + + + + + + + DB_AUTH = "Windows Authentication" + NOT(DB_AUTH = "Windows Authentication") + + + + + + DB_CONN_CORRECT="0" + DB_CONN_CORRECT="1" + + + DB_CONN_CORRECT="0" + DB_CONN_CORRECT="1" + + + + + + + Connection not valid. [DB_CONN_MSG] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOT(PI_PORTAL_CREATE_AD = "1") + PI_PORTAL_CREATE_AD = "1" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PI_PREREQ_OS="1" AND PI_PREREQ_IIS="1" AND PI_PREREQ_ASPNET="1" + + + + + + + + + + + + + + + + + + + [VALIDATE_MSG] + + + + + LicenseAccepted = "1" + + 1 + 1 + 1 + + 1 + &ServerFeature=3 + &EnterpriseServerFeature=3 + &PortalFeature=3 + &SchedulerServiceFeature=3 + &WDPortalFeature=3 + 1 + 1 + + 1 + 1 + 1 + + 1 + VALIDATE_OK="1" + VALIDATE_OK="0" + 1 + 1 + + 1 + 1 + 1 + 1 + 1 + ""]]> + "" AND DSOP_UPN = ""]]> + + 1 + &EnterpriseServerFeature=3 AND VALIDATE_OK = "1" + &PortalFeature=3 AND VALIDATE_OK = "1" + &SchedulerServiceFeature=3 AND VALIDATE_OK = "1" + &WDPortalFeature=3 AND VALIDATE_OK = "1" + + + + VALIDATE_OK = "0" + 1 + 1 + + + 1 + 1 + 1 + 1 + + 1 + VALIDATE_OK="1" + VALIDATE_OK="0" + 1 + 1 + + 1 + 1 + 1 + 1 + 1 + ""]]> + "" AND DSOP_UPN = ""]]> + + 1 + + VALIDATE_OK="0" + 1 + 1 + + + + + 1 + &PortalFeature=3 AND DB_CONN_CORRECT="1" AND VALIDATE_OK = "1" + DB_CONN_CORRECT = "1" AND VALIDATE_OK = "1" + VALIDATE_OK = "0" + 1 + 1 + DB_CONN_CORRECT = "0" + 1 + 1 + 1 + 1 + + 1 + + 1 + 1 + 1 + + + + 1 + 1 + 1 + + 1 + + + VALIDATE_OK="0" + 1 + 1 + + 1 + 1 + 1 + 1 + 1 + ""]]> + "" AND DSOP_UPN = ""]]> + + 1 + + 1 + 1 + + + + + 3]]> + 3 AND &PortalFeature<>3]]> + 1 + + 1 + + 1 + + + + + + + + + + + + + + + + + + + + + bannrbmp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WSP_ROOT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (NOT Installed OR NOT WIX_UPGRADE_DETECTED) AND NOT(DB_AUTH = "Windows Authentication") + + + + + + + NOT (Remove="ALL") AND NOT(DB_AUTH = "Windows Authentication") + + + + + + + (NOT Installed OR NOT WIX_UPGRADE_DETECTED) AND (DB_AUTH = "Windows Authentication") + + + + + + NOT (Remove="ALL") AND (DB_AUTH = "Windows Authentication") + + + + + - - \ No newline at end of file + + + + + + + + + + + diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Setup.WIXInstaller.wixproj b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Setup.WIXInstaller.wixproj index ab5acac6..7278ed94 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Setup.WIXInstaller.wixproj +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Setup.WIXInstaller.wixproj @@ -3,7 +3,7 @@ Debug x86 - 3.7 + 3.9 {978f0a18-7c81-4561-8f6d-5a165484ad0a} 2.0 Websitepanel @@ -14,35 +14,50 @@ bin\ obj\$(Configuration)\ - Debug;BUILD=debug + Debug;BUILD=debug;Version=$(Version);BuildDate=$(ReleaseDate) False - + bin\$(Configuration)\ obj\$(Configuration)\ - BUILD=release + BUILD=release;Version=$(Version);BuildDate=$(ReleaseDate) - - + - + + + + + ..\..\..\tools\WIX\WixUIExtension.dll WixUIExtension + + ..\..\..\tools\WIX\WixIIsExtension.dll + WixIIsExtension + + + ..\..\..\tools\WIX\WixSqlExtension.dll + WixSqlExtension + + + ..\..\..\tools\WIX\WixUtilExtension.dll + WixUtilExtension + - \ No newline at end of file + diff --git a/WebsitePanel.Installer/Sources/VersionInfo.cs b/WebsitePanel.Installer/Sources/VersionInfo.cs index 4f3d2fdf..9df3788e 100644 --- a/WebsitePanel.Installer/Sources/VersionInfo.cs +++ b/WebsitePanel.Installer/Sources/VersionInfo.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18051 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Installer.sln b/WebsitePanel.Installer/Sources/WebsitePanel.Installer.sln index 6185b28b..95ec3f32 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Installer.sln +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Installer.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 +VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{129305D5-A9E6-4DCE-BFF6-41809E13EEEE}" ProjectSection(SolutionItems) = preProject @@ -33,6 +33,13 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup.SchedulerService", "S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.SchedulerServiceInstaller", "WebsitePanel.SchedulerServiceInstaller\WebsitePanel.SchedulerServiceInstaller.csproj", "{24A4C231-73A9-4F03-ABAD-9A8FE5324495}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.WIXInstaller", "WebsitePanel.WIXInstaller\WebsitePanel.WIXInstaller.csproj", "{3343FFD8-7CCE-451B-95AE-3D97244313A2}" +EndProject +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup.WIXInstaller", "Setup.WIXInstaller\Setup.WIXInstaller.wixproj", "{978F0A18-7C81-4561-8F6D-5A165484AD0A}" + ProjectSection(ProjectDependencies) = postProject + {3343FFD8-7CCE-451B-95AE-3D97244313A2} = {3343FFD8-7CCE-451B-95AE-3D97244313A2} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -125,6 +132,26 @@ Global {24A4C231-73A9-4F03-ABAD-9A8FE5324495}.Release|Mixed Platforms.Build.0 = Release|x86 {24A4C231-73A9-4F03-ABAD-9A8FE5324495}.Release|x86.ActiveCfg = Release|x86 {24A4C231-73A9-4F03-ABAD-9A8FE5324495}.Release|x86.Build.0 = Release|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|Any CPU.ActiveCfg = Debug|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|x86.ActiveCfg = Debug|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|x86.Build.0 = Debug|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|Any CPU.ActiveCfg = Release|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|Mixed Platforms.Build.0 = Release|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|x86.ActiveCfg = Release|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|x86.Build.0 = Release|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|Any CPU.ActiveCfg = Debug|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|x86.ActiveCfg = Debug|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|x86.Build.0 = Debug|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|Any CPU.ActiveCfg = Release|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|Mixed Platforms.Build.0 = Release|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|x86.ActiveCfg = Release|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Installer/Updater.exe b/WebsitePanel.Installer/Sources/WebsitePanel.Installer/Updater.exe index 113e18c1..b2a7fa47 100644 Binary files a/WebsitePanel.Installer/Sources/WebsitePanel.Installer/Updater.exe and b/WebsitePanel.Installer/Sources/WebsitePanel.Installer/Updater.exe differ diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs index c6279ca0..3680e837 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs @@ -67,37 +67,21 @@ namespace WebsitePanel.Setup.Actions { OnInstallProgressChanged(LogStartInstallMessage, 0); Log.WriteStart(LogStartInstallMessage); - - var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile); - vars.CryptoKey = Utils.GetRandomString(20); - - // load file - string content = string.Empty; - using (StreamReader reader = new StreamReader(file)) - { - content = reader.ReadToEnd(); - } - - // expand variables - content = Utils.ReplaceScriptVariable(content, "installer.cryptokey", vars.CryptoKey); - // - Log.WriteInfo(String.Format("The following cryptographic key has been generated: '{0}'", vars.CryptoKey)); - - // save file - using (StreamWriter writer = new StreamWriter(file)) - { - writer.Write(content); - } - //update log + var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile); + vars.CryptoKey = Utils.GetRandomString(20); + var Xml = new XmlDocument(); + Xml.Load(file); + var CryptoNode = Xml.SelectSingleNode("configuration/appSettings/add[@key='WebsitePanel.CryptoKey']") as XmlElement; + if (CryptoNode != null) + CryptoNode.SetAttribute("value", vars.CryptoKey); + Xml.Save(file); Log.WriteEnd(LogEndInstallMessage); } catch (Exception ex) { if (Utils.IsThreadAbortException(ex)) return; - // Log.WriteError("Update web.config error", ex); - // throw; } } @@ -116,6 +100,10 @@ namespace WebsitePanel.Setup.Actions Begin(LogStartInstallMessage); Log.WriteStart(LogStartInstallMessage); + + var ServiceName = Global.Parameters.SchedulerServiceName; + var ServiceFile = Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName); + Log.WriteInfo(String.Format("Scheduler Service Name: \"{0}\"", Global.Parameters.SchedulerServiceName)); if (ServiceController.GetServices().Any(s => s.DisplayName.Equals(Global.Parameters.SchedulerServiceName, StringComparison.CurrentCultureIgnoreCase))) @@ -125,8 +113,13 @@ namespace WebsitePanel.Setup.Actions return; } - ManagedInstallerClass.InstallHelper(new[] { "/i", Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName) }); + ManagedInstallerClass.InstallHelper(new[] { "/i /LogFile=\"\" ", ServiceFile }); Utils.StartService(Global.Parameters.SchedulerServiceName); + + AppConfig.EnsureComponentConfig(vars.ComponentId); + AppConfig.SetComponentSettingStringValue(vars.ComponentId, "ServiceName", ServiceName); + AppConfig.SetComponentSettingStringValue(vars.ComponentId, "ServiceFile", ServiceFile); + AppConfig.SaveConfiguration(); } catch (Exception ex) { @@ -166,7 +159,7 @@ namespace WebsitePanel.Setup.Actions { if (ServiceController.GetServices().Any(s => s.ServiceName.Equals(Global.Parameters.SchedulerServiceName, StringComparison.CurrentCultureIgnoreCase))) { - ManagedInstallerClass.InstallHelper(new[] { "/u", Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName) }); + ManagedInstallerClass.InstallHelper(new[] { "/u /LogFile=\"\" ", Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName) }); } } } @@ -397,25 +390,14 @@ namespace WebsitePanel.Setup.Actions void IInstallAction.Run(SetupVariables vars) { Log.WriteStart("Updating web.config file (connection string)"); - // var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile); - // - var content = String.Empty; - // load file - using (StreamReader reader = new StreamReader(file)) - { - content = reader.ReadToEnd(); - } - // Build connection string vars.ConnectionString = String.Format(vars.ConnectionString, vars.DatabaseServer, vars.Database, vars.Database, vars.DatabaseUserPassword); - // Expand variables - content = Utils.ReplaceScriptVariable(content, "installer.connectionstring", vars.ConnectionString); - // Save file - using (StreamWriter writer = new StreamWriter(file)) - { - writer.Write(content); - } - // + var Xml = new XmlDocument(); + Xml.Load(file); + var ConnNode = Xml.SelectSingleNode("configuration/connectionStrings/add[@name='EnterpriseServer']") as XmlElement; + if(ConnNode != null) + ConnNode.SetAttribute("connectionString", vars.ConnectionString); + Xml.Save(file); Log.WriteEnd(String.Format("Updated {0} file", vars.ConfigurationFile)); } } @@ -509,10 +491,11 @@ namespace WebsitePanel.Setup.Actions { void IInstallAction.Run(SetupVariables vars) { + Log.WriteStart("SaveEntServerConfigSettingsAction"); AppConfig.EnsureComponentConfig(vars.ComponentId); // AppConfig.SetComponentSettingStringValue(vars.ComponentId, "Database", vars.Database); - AppConfig.SetComponentSettingBooleanValue(vars.ComponentId, "NewDatabase", true); + AppConfig.SetComponentSettingBooleanValue(vars.ComponentId, "NewDatabase", vars.CreateDatabase); // AppConfig.SetComponentSettingStringValue(vars.ComponentId, "DatabaseUser", vars.Database); AppConfig.SetComponentSettingBooleanValue(vars.ComponentId, "NewDatabaseUser", vars.NewDatabaseUser); @@ -523,6 +506,7 @@ namespace WebsitePanel.Setup.Actions AppConfig.SetComponentSettingStringValue(vars.ComponentId, Global.Parameters.CryptoKey, vars.CryptoKey); // AppConfig.SaveConfiguration(); + Log.WriteEnd("SaveEntServerConfigSettingsAction"); } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/AppConfig.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/AppConfig.cs index 00fb1421..a964a0c2 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/AppConfig.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/AppConfig.cs @@ -38,25 +38,27 @@ namespace WebsitePanel.Setup public sealed class AppConfig { public const string AppConfigFileNameWithoutExtension = "WebsitePanel.Installer.exe"; - + static AppConfig() + { + ConfigurationPath = DefaultConfigurationPath; + } private AppConfig() { + } - private static Configuration appConfig = null; private static XmlDocument xmlConfig = null; - - public static void LoadConfiguration() + public static string ConfigurationPath { get; set; } + public static string DefaultConfigurationPath { get { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppConfigFileNameWithoutExtension); } } + public static void LoadConfiguration(ExeConfigurationFileMap FnMap = null, ConfigurationUserLevel CuLevel = ConfigurationUserLevel.None) { - // - var exePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppConfigFileNameWithoutExtension); - // - appConfig = ConfigurationManager.OpenExeConfiguration(exePath); - // + if (FnMap == null) + appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationPath); + else + appConfig = ConfigurationManager.OpenMappedExeConfiguration(FnMap, CuLevel); ConfigurationSection section = appConfig.Sections["installer"]; if (section == null) - throw new ConfigurationErrorsException("instalelr section not found"); - + throw new ConfigurationErrorsException("installer section not found in " + appConfig.FilePath); string strXml = section.SectionInformation.GetRawXml(); xmlConfig = new XmlDocument(); xmlConfig.LoadXml(strXml); diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/CopyProcess.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/CopyProcess.cs index 4d7c8ba6..6c58ff69 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/CopyProcess.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/CopyProcess.cs @@ -48,9 +48,9 @@ namespace WebsitePanel.Setup /// Progress bar. /// Source folder. /// Destination folder. - public CopyProcess(ProgressBar bar, string source, string destination) + public CopyProcess(object bar, string source, string destination) { - this.progressBar = bar; + this.progressBar = bar as ProgressBar; this.sourceFolder = new DirectoryInfo(source); this.destFolder = new DirectoryInfo(destination); } @@ -63,9 +63,13 @@ namespace WebsitePanel.Setup // unzip long totalSize = FileUtils.CalculateFolderSize(sourceFolder.FullName); long copied = 0; - progressBar.Minimum = 0; - progressBar.Maximum = 100; - progressBar.Value = 0; + + if (progressBar != null) + { + progressBar.Minimum = 0; + progressBar.Maximum = 100; + progressBar.Value = 0; + } int i = 0; List folders = new List(); @@ -122,7 +126,10 @@ namespace WebsitePanel.Setup copied += files[i].Length; if (totalSize != 0) { - progressBar.Value = Convert.ToInt32(copied * 100 / totalSize); + if (progressBar != null) + { + progressBar.Value = Convert.ToInt32(copied * 100 / totalSize); + } } } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Log.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Log.cs index d2cd6d04..3c74bfda 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Log.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Log.cs @@ -170,5 +170,7 @@ namespace WebsitePanel.Setup } catch { } } + + public static TraceListenerCollection Listeners { get { return Trace.Listeners; } } } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs index 23ef37c1..c41de825 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs @@ -286,7 +286,8 @@ namespace WebsitePanel.Setup Windows7, WindowsServer2008R2, Windows8, - WindowsServer2012 + WindowsServer2012, + WindowsServer2012R2 } public static string GetName(WindowsVersion version) @@ -428,6 +429,9 @@ namespace WebsitePanel.Setup else ret = WindowsVersion.WindowsServer2012; break; + case 3: + ret = WindowsVersion.WindowsServer2012R2; + break; } break; } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs index 70767919..072723fb 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs @@ -338,8 +338,8 @@ namespace WebsitePanel.Setup /// /// internal static string GetSid(string userAccount, string domain) - { - if(domain == null) + { + if(string.IsNullOrWhiteSpace(domain)) domain = Environment.MachineName; // try to get user account diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs index b7509c87..ecf6ed15 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs @@ -481,11 +481,11 @@ namespace WebsitePanel.Setup public static void StopService(string serviceName) { ServiceController sc = new ServiceController(serviceName); - // Start the service if the current status is stopped. + // Stop the service if the current status is not stopped. if (sc.Status != ServiceControllerStatus.Stopped && sc.Status != ServiceControllerStatus.StopPending) { - // Start the service, and wait until its status is "Running". + // Stop the service, and wait until its status is "Running". sc.Stop(); sc.WaitForStatus(ServiceControllerStatus.Stopped); } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/WebUtils.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/WebUtils.cs index 4f57fd97..6b3781b8 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/WebUtils.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/WebUtils.cs @@ -150,7 +150,7 @@ namespace WebsitePanel.Setup FileUtils.CreateDirectory(path); SecurityUtils.GrantNtfsPermissions(path, userDomain, userAccount, NtfsPermission.Modify, true, true); - SecurityUtils.GrantNtfsPermissionsBySid(path, SystemSID.NETWORK_SERVICE, NtfsPermission.Modify, true, true); + SecurityUtils.GrantNtfsPermissionsBySid(path, SystemSID.NETWORK_SERVICE, NtfsPermission.Modify, true, true); } /// diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/ZipIndicator.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/ZipIndicator.cs index 68be9581..017cc820 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/ZipIndicator.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/ZipIndicator.cs @@ -46,9 +46,9 @@ namespace WebsitePanel.Setup.Common int totalFiles = 0; int files = 0; - public ZipIndicator(ProgressBar progressBar, string sourcePath, string zipFile) + public ZipIndicator(object progressBar, string sourcePath, string zipFile) { - this.progressBar = progressBar; + this.progressBar = progressBar as ProgressBar; this.sourcePath = sourcePath; this.zipFile = zipFile; } @@ -71,8 +71,11 @@ namespace WebsitePanel.Setup.Common { string fileName = e.CurrentEntry.FileName; files++; - this.progressBar.Value = Convert.ToInt32(files * 100 / totalFiles); - this.progressBar.Update(); + if (this.progressBar != null) + { + this.progressBar.Value = Convert.ToInt32(files * 100 / totalFiles); + this.progressBar.Update(); + } } } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj index f8a058bc..246d4850 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj @@ -143,6 +143,7 @@ + diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs index db4610e2..20344e42 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs @@ -127,13 +127,13 @@ namespace WebsitePanel.Setup switch (check.CheckType) { case CheckTypes.OperationSystem: - status = CheckOS(out details); + status = CheckOS(check.SetupVariables, out details); break; case CheckTypes.IISVersion: - status = CheckIISVersion(out details); + status = CheckIISVersion(check.SetupVariables, out details); break; case CheckTypes.ASPNET: - status = CheckASPNET(out details); + status = CheckASPNET(check.SetupVariables, out details); break; case CheckTypes.WPServer: status = CheckWPServer(check.SetupVariables, out details); @@ -221,7 +221,7 @@ namespace WebsitePanel.Setup } - private CheckStatuses CheckOS(out string details) + internal static CheckStatuses CheckOS(SetupVariables setupVariables, out string details) { details = string.Empty; try @@ -237,6 +237,7 @@ namespace WebsitePanel.Setup version == OS.WindowsVersion.WindowsServer2008 || version == OS.WindowsVersion.WindowsServer2008R2 || version == OS.WindowsVersion.WindowsServer2012 || + version == OS.WindowsVersion.WindowsServer2012R2 || version == OS.WindowsVersion.WindowsVista || version == OS.WindowsVersion.Windows7 || version == OS.WindowsVersion.Windows8 )) @@ -260,20 +261,20 @@ namespace WebsitePanel.Setup return CheckStatuses.Error; } } - private CheckStatuses CheckIISVersion(out string details) + internal static CheckStatuses CheckIISVersion(SetupVariables setupVariables, out string details) { details = string.Empty; try { - details = string.Format("IIS {0}", SetupVariables.IISVersion.ToString(2)); - if (SetupVariables.IISVersion.Major == 6 && + details = string.Format("IIS {0}", setupVariables.IISVersion.ToString(2)); + if (setupVariables.IISVersion.Major == 6 && Utils.IsWin64() && Utils.IIS32Enabled()) { details += " (32-bit mode)"; } Log.WriteInfo(string.Format("IIS check: {0}", details)); - if (SetupVariables.IISVersion.Major < 6) + if (setupVariables.IISVersion.Major < 6) { details = "IIS 6.0 or greater required."; Log.WriteError(string.Format("IIS check: {0}", details), null); @@ -291,26 +292,26 @@ namespace WebsitePanel.Setup } } - private CheckStatuses CheckASPNET(out string details) + internal static CheckStatuses CheckASPNET(SetupVariables setupVariables, out string details) { details = "ASP.NET 4.0 is installed."; CheckStatuses ret = CheckStatuses.Success; try { // IIS 6 - if (SetupVariables.IISVersion.Major == 6) + if (setupVariables.IISVersion.Major == 6) { // - if (Utils.CheckAspNet40Registered(SetupVariables) == false) + if (Utils.CheckAspNet40Registered(setupVariables) == false) { // Register ASP.NET 4.0 - Utils.RegisterAspNet40(SetupVariables); + Utils.RegisterAspNet40(setupVariables); // ret = CheckStatuses.Warning; details = AspNet40HasBeenInstalledMessage; } // Enable ASP.NET 4.0 Web Server Extension if it is prohibited - if (Utils.GetAspNetWebExtensionStatus_Iis6(SetupVariables) == WebExtensionStatus.Prohibited) + if (Utils.GetAspNetWebExtensionStatus_Iis6(setupVariables) == WebExtensionStatus.Prohibited) { Utils.EnableAspNetWebExtension_Iis6(); } @@ -331,10 +332,10 @@ namespace WebsitePanel.Setup return CheckStatuses.Error; } // Register ASP.NET 4.0 - if (Utils.CheckAspNet40Registered(SetupVariables) == false) + if (Utils.CheckAspNet40Registered(setupVariables) == false) { // Register ASP.NET 4.0 - Utils.RegisterAspNet40(SetupVariables); + Utils.RegisterAspNet40(setupVariables); // ret = CheckStatuses.Warning; details = AspNet40HasBeenInstalledMessage; @@ -359,17 +360,17 @@ namespace WebsitePanel.Setup } } - private CheckStatuses CheckIIS32Mode(out string details) + internal static CheckStatuses CheckIIS32Mode(SetupVariables setupVariables, out string details) { details = string.Empty; - CheckStatuses ret = CheckIISVersion(out details); + CheckStatuses ret = CheckIISVersion(setupVariables, out details); if (ret == CheckStatuses.Error) return ret; try { //IIS 6 - if (SetupVariables.IISVersion.Major == 6) + if (setupVariables.IISVersion.Major == 6) { //x64 if (Utils.IsWin64()) diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs index 1ce53461..d9c553dc 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs @@ -25,51 +25,244 @@ // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - using System; using System.Collections.Generic; using System.Configuration.Install; using System.Data; +using System.Data.Sql; using System.Data.SqlClient; +using System.Diagnostics; using System.IO; using System.Linq; +using System.Net.NetworkInformation; +using System.Net.Sockets; using System.ServiceProcess; using System.Text.RegularExpressions; -using System.Threading; -using System.Windows.Forms; -using System.Windows.Forms.VisualStyles; using System.Xml; using Microsoft.Deployment.WindowsInstaller; using WebsitePanel.Setup; +using WebsitePanel.Setup.Internal; +using WebsitePanel.WIXInstaller.Common; +using WebsitePanel.WIXInstaller.Common.Util; namespace WebsitePanel.WIXInstaller { public class CustomActions { + public static List SysDb = new List { "tempdb", "master", "model", "msdb" }; public const string CustomDataDelimiter = "-=del=-"; + #region CustomActions + // Install. [CustomAction] - public static ActionResult CheckConnection(Session session) + public static ActionResult OnServerInstall(Session session) { - string testConnectionString = session["AUTHENTICATIONTYPE"].Equals("Windows Authentication") ? GetConnectionString(session["SERVERNAME"], "master") : GetConnectionString(session["SERVERNAME"], "master", session["LOGIN"], session["PASSWORD"]); - - if (CheckConnection(testConnectionString)) + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.InstallServer); + } + [CustomAction] + public static ActionResult OnEServerInstall(Session session) + { + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.InstallEnterpriseServer); + } + [CustomAction] + public static ActionResult OnPortalInstall(Session session) + { + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.InstallPortal); + } + // Remove. + [CustomAction] + public static ActionResult OnServerRemove(Session session) + { + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.RemoveServer); + } + [CustomAction] + public static ActionResult OnEServerRemove(Session session) + { + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.RemoveEnterpriseServer); + } + [CustomAction] + public static ActionResult OnPortalRemove(Session session) + { + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.RemovePortal); + } + // Other. + [CustomAction] + public static ActionResult SetEServerUrlUI(Session session) + { + var Ctx = session; + Ctx["PI_ESERVER_URL"] = string.Format("http://{0}:{1}/", Ctx["PI_ESERVER_IP"], Ctx["PI_ESERVER_PORT"]); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult RecapListUI(Session session) + { + const string F_WSP = "WebsitePanel"; + const string F_Server = "ServerFeature"; + const string F_EServer = "EnterpriseServerFeature"; + const string F_Portal = "PortalFeature"; + const string F_Scheduler = "SchedulerServiceFeature"; + const string F_WDPosrtal = "WDPortalFeature"; + var S_Install = new List { "Copy WebsitePanel Server files", "Add WebsitePanel Server website" }; + var ES_Install = new List { "Copy WebsitePanel Enterprise Server files", "Install WebsitePanel database and updates", "Add WebsitePanel Enterprise Server website" }; + var P_Install = new List { "Copy WebsitePanel Portal files", "Add WebsitePanel Enterprise Portal website" }; + var SCH_Install = new List { "Copy WebsitePanel Scheduler Service files", "Install Scheduler Service Windows Service" }; + var WDP_Install = new List { "Copy WebsitePanel WebDav Portal files" }; + var S_Uninstall = new List { "Delete WebsitePanel Server files", "Remove WebsitePanel Server website" }; + var ES_Uninstall = new List { "Delete WebsitePanel Enterprise Server files", "Keep WebsitePanel database and updates", "Remove WebsitePanel Enterprise Server website" }; + var P_Uninstall = new List { "Delete WebsitePanel Portal files", "Remove WebsitePanel Enterprise Portal website" }; + var SCH_Uninstall = new List { "Delete WebsitePanel Scheduler Service files", "Remove Scheduler Service Windows Service" }; + var WDP_Uninstall = new List { "Delete WebsitePanel WebDav Portal files" }; + var RecapList = new List(); + var EmptyList = new List(); + var Ctx = session; + RecapListReset(Ctx); + foreach (var Feature in Ctx.Features) { - session["CORRECTCONNECTION"] = "1"; - session["CONNECTIONSTRING"] = session["AUTHENTICATIONTYPE"].Equals("Windows Authentication") ? GetConnectionString(session["SERVERNAME"], session["DATABASENAME"]) : GetConnectionString(session["SERVERNAME"], session["DATABASENAME"], session["LOGIN"], session["PASSWORD"]); + switch (Feature.Name) + { + case F_WSP: + break; + case F_Server: + RecapList.AddRange(Feature.RequestState == InstallState.Local ? S_Install : /*S_Uninstall*/ EmptyList); + break; + case F_EServer: + RecapList.AddRange(Feature.RequestState == InstallState.Local ? ES_Install : /*ES_Uninstall*/ EmptyList); + break; + case F_Portal: + RecapList.AddRange(Feature.RequestState == InstallState.Local ? P_Install : /*P_Uninstall*/ EmptyList); + break; + case F_Scheduler: + RecapList.AddRange(Feature.RequestState == InstallState.Local ? SCH_Install : /*SCH_Uninstall*/ EmptyList); + break; + case F_WDPosrtal: + RecapList.AddRange(Feature.RequestState == InstallState.Local ? WDP_Install : /*WDP_Uninstall*/ EmptyList); + break; + default: + break; + } } + RecapListAdd(Ctx, RecapList.ToArray()); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult DatabaseConnectionValidateUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidateDbNameUI(Ctx, out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult ServerAdminValidateUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidatePasswordUI(Ctx, "SERVERADMIN", out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult ServerValidateADUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidateADUI(Ctx, "PI_SERVER", out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult EServerValidateADUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidateADUI(Ctx, "PI_ESERVER", out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult PortalValidateADUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidateADUI(Ctx, "PI_PORTAL", out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult ServerAccessValidateUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidatePasswordUI(Ctx, "SERVER_ACCESS", out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult SqlServerListUI(Session session) + { + var Ctx = session; + var SrvList = new ComboBoxCtrl(Ctx, "DB_SERVER"); + foreach (var Srv in GetSqlInstances()) + SrvList.AddItem(Srv); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult DbListUI(Session session) + { + string tmp; + var Ctrl = new ComboBoxCtrl(session, "DB_SELECT"); + if (CheckConnection(session["DB_CONN"], out tmp)) + foreach (var Db in GetDbList(ConnStr: session["DB_CONN"], ForbiddenNames: SysDb)) + { + Ctrl.AddItem(Db); + session["DB_SELECT"] = Db; // Adds available DBs to installer log. + } else - { - session["CORRECTCONNECTION"] = "0"; - } - + session["DB_SELECT"] = ""; + return ActionResult.Success; + } + [CustomAction] + public static ActionResult CheckConnectionUI(Session session) + { + string ConnStr = session["DB_AUTH"].Equals("Windows Authentication") ? GetConnectionString(session["DB_SERVER"], "master") : + GetConnectionString(session["DB_SERVER"], "master", session["DB_LOGIN"], session["DB_PASSWORD"]); + string msg; + bool Result = CheckConnection(ConnStr, out msg); + session["DB_CONN_CORRECT"] = Result ? "1" : "0"; + session["DB_CONN"] = Result ? ConnStr : ""; + session["DB_CONN_MSG"] = msg; return ActionResult.Success; } [CustomAction] public static ActionResult FinalizeInstall(Session session) { - var connectionString = GetCustomActionProperty(session, "ConnectionString").Replace(CustomDataDelimiter, ";"); + /*var connectionString = GetCustomActionProperty(session, "ConnectionString").Replace(CustomDataDelimiter, ";"); var serviceFolder = GetCustomActionProperty(session, "ServiceFolder"); var previousConnectionString = GetCustomActionProperty(session, "PreviousConnectionString").Replace(CustomDataDelimiter, ";"); var previousCryptoKey = GetCustomActionProperty(session, "PreviousCryptoKey"); @@ -85,7 +278,7 @@ namespace WebsitePanel.WIXInstaller ChangeConfigString("/configuration/connectionStrings/add[@name='EnterpriseServer']", "connectionString", connectionString, serviceFolder); ChangeConfigString("/configuration/appSettings/add[@key='WebsitePanel.CryptoKey']", "value", previousCryptoKey, serviceFolder); - InstallService(serviceFolder); + InstallService(serviceFolder);*/ return ActionResult.Success; } @@ -93,7 +286,7 @@ namespace WebsitePanel.WIXInstaller [CustomAction] public static ActionResult FinalizeUnInstall(Session session) { - UnInstallService(); + // UnInstallService(); return ActionResult.Success; } @@ -105,7 +298,7 @@ namespace WebsitePanel.WIXInstaller session["SERVICEFOLDER"] = session["INSTALLFOLDER"]; - var servicePath = SecurityUtils.GetServicePath("WebsitePanel Scheduler"); + var servicePath = /*SecurityUtils.GetServicePath("WebsitePanel Scheduler")*/""; if (!string.IsNullOrEmpty(servicePath)) { @@ -131,13 +324,59 @@ namespace WebsitePanel.WIXInstaller { session["SERVICEFOLDER"] = servicePath; } - } + } } return ActionResult.Success; } + [CustomAction] + public static ActionResult PrereqCheck(Session session) + { + string Msg; + var Ctx = Tool.GetSetupVars(session); + var ros = Adapter.CheckOS(Ctx, out Msg); + AddLog(session, Msg); + var riis = Adapter.CheckIIS(Ctx, out Msg); + AddLog(session, Msg); + var raspnet = Adapter.CheckASPNET(Ctx, out Msg); + AddLog(session, Msg); + session[Prop.REQ_OS] = ros == CheckStatuses.Success ? YesNo.Yes : YesNo.No; + session[Prop.REQ_IIS] = riis == CheckStatuses.Success ? YesNo.Yes : YesNo.No; ; + session[Prop.REQ_ASPNET] = raspnet == CheckStatuses.Success ? YesNo.Yes : YesNo.No; ; + session[Prop.REQ_SERVER] = YesNo.Yes; + session[Prop.REQ_ESERVER] = YesNo.Yes; + session[Prop.REQ_PORTAL] = YesNo.Yes; + session[Prop.REQ_WDPORTAL] = YesNo.Yes; + return ActionResult.Success; + } + [CustomAction] + public static ActionResult PrereqCheckUI(Session session) + { + var ListView = new ListViewCtrl(session, "REQCHECKLIST"); + AddCheck(ListView, session, Prop.REQ_OS); + AddCheck(ListView, session, Prop.REQ_IIS); + AddCheck(ListView, session, Prop.REQ_ASPNET); + AddCheck(ListView, session, Prop.REQ_SERVER); + AddCheck(ListView, session, Prop.REQ_ESERVER); + AddCheck(ListView, session, Prop.REQ_PORTAL); + AddCheck(ListView, session, Prop.REQ_WDPORTAL); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult FillIpListUI(Session session) + { + var Ctrls = new[]{ new ComboBoxCtrl(session, "PI_SERVER_IP"), + new ComboBoxCtrl(session, "PI_ESERVER_IP"), + new ComboBoxCtrl(session, "PI_PORTAL_IP") }; + foreach (var Ip in GetIpList()) + foreach (var Ctrl in Ctrls) + Ctrl.AddItem(Ip); + return ActionResult.Success; + } + + #endregion private static void InstallService(string installFolder) { try @@ -204,7 +443,6 @@ namespace WebsitePanel.WIXInstaller } } - private static void StopService(string serviceName) { var sc = new ServiceController(serviceName); @@ -229,36 +467,30 @@ namespace WebsitePanel.WIXInstaller private static string GetConnectionString(string serverName, string databaseName) { - return string.Format("Server={0};database={1};Trusted_Connection=true;", serverName, databaseName).Replace(";", CustomDataDelimiter); + return string.Format("Server={0};database={1};Trusted_Connection=true;", serverName, databaseName)/*.Replace(";", CustomDataDelimiter)*/; } private static string GetConnectionString(string serverName, string databaseName, string login, string password) { - return string.Format("Server={0};database={1};uid={2};password={3};", serverName, databaseName, login, password).Replace(";", CustomDataDelimiter); + return string.Format("Server={0};database={1};uid={2};password={3};", serverName, databaseName, login, password)/*.Replace(";", CustomDataDelimiter)*/; } - - private static bool CheckConnection(string connectionString) + static bool CheckConnection(string ConnStr, out string Info) { - var connection = new SqlConnection(connectionString); - bool result = true; - - try + Info = string.Empty; + bool Result = false; + using (var Conn = new SqlConnection(ConnStr)) { - connection.Open(); - } - catch (Exception) - { - result = false; - } - finally - { - if (connection != null && connection.State == ConnectionState.Open) + try { - connection.Close(); + Conn.Open(); + Result = true; + } + catch (Exception ex) + { + Info = ex.Message; } } - - return result; + return Result; } private static string GetCustomActionProperty(Session session, string key) @@ -270,5 +502,235 @@ namespace WebsitePanel.WIXInstaller return string.Empty; } + private static void AddCheck(ListViewCtrl view, Session session, string PropertyID) + { + view.AddItem(session[PropertyID] == YesNo.Yes, session[PropertyID + "_TITLE"]); + } + static IList GetSqlInstances() + { + var Result = new List(); + using (var Src = SqlDataSourceEnumerator.Instance.GetDataSources()) + { + foreach (DataRow Row in Src.Rows) + { + var Instance = Row["InstanceName"].ToString(); + Result.Add((string.IsNullOrWhiteSpace(Instance) ? "" : (Instance + "\\")) + Row["ServerName"].ToString()); + } + } + return Result; + } + static IEnumerable GetDbList(string ConnStr, IList ForbiddenNames = null) + { + using (var Conn = new SqlConnection(ConnStr)) + { + Conn.Open(); + var Cmd = Conn.CreateCommand(); + Cmd.CommandText = "SELECT name FROM master..sysdatabases"; + if (ForbiddenNames != null && ForbiddenNames.Count > 0) + Cmd.CommandText += string.Format(" WHERE name NOT IN ({0})", string.Join(", ", ForbiddenNames.Select(x => string.Format("'{0}'", x)))); + var Result = Cmd.ExecuteReader(); + while (Result.Read()) + yield return Result["name"].ToString(); + } + } + static IEnumerable GetIpList() + { + foreach (var Ni in NetworkInterface.GetAllNetworkInterfaces()) + if (Ni.OperationalStatus == OperationalStatus.Up && (Ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet || + Ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || + Ni.NetworkInterfaceType == NetworkInterfaceType.Loopback)) + foreach (var IpInfo in Ni.GetIPProperties().UnicastAddresses) + if (IpInfo.Address.AddressFamily == AddressFamily.InterNetwork) + yield return IpInfo.Address.ToString(); + } + internal static void AddLog(Session Ctx, string Msg) + { + AddTo(Ctx, "PI_PREREQ_LOG", Msg); + } + internal static void AddTo(Session Ctx, string TextProp, string Msg) + { + if (!string.IsNullOrWhiteSpace(Msg)) + { + string tmp = Ctx[TextProp]; + if (string.IsNullOrWhiteSpace(tmp)) + Ctx[TextProp] = Msg; + else + Ctx[TextProp] = tmp + Environment.NewLine + Msg; + } + } + internal static void ValidationReset(Session Ctx) + { + Ctx["VALIDATE_OK"] = "0"; + Ctx["VALIDATE_MSG"] = "Error occurred."; + } + internal static void ValidationStatus(Session Ctx, bool Value) + { + Ctx["VALIDATE_OK"] = Value ? YesNo.Yes : YesNo.No; + } + internal static void ValidationMsg(Session Ctx, string Msg) + { + AddTo(Ctx, "VALIDATE_MSG", Msg); + } + internal static bool PasswordValidate(string Password, string Confirm, out string Msg) + { + Msg = string.Empty; + bool Result = false; + if (string.IsNullOrWhiteSpace(Password)) + Msg = "Empty password."; + else if (Password != Confirm) + Msg = "Password does not match the confirm password. Type both passwords again."; + else + Result = true; + return Result; + } + internal static bool ValidatePasswordUI(Session Ctx, string Ns, out string Msg) + { + string p1 = Ctx[Ns + "_PASSWORD"]; + string p2 = Ctx[Ns + "_PASSWORD_CONFIRM"]; + return PasswordValidate(p1, p2, out Msg); + } + internal static bool ValidateADDomainUI(Session Ctx, string Ns, out string Msg) + { + bool Result = default(bool); + bool check = Ctx[Ns + "_CREATE_AD"] == YesNo.Yes; + string name = Ctx[Ns + "_DOMAIN"]; + if (check && string.IsNullOrWhiteSpace(name)) + { + Result = false; + Msg = "The domain can't be empty."; + } + else + { + Result = true; + Msg = string.Empty; + } + return Result; + } + internal static bool ValidateADLoginUI(Session Ctx, string Ns, out string Msg) + { + bool Result = default(bool); + string name = Ctx[Ns + "_LOGIN"]; + if (string.IsNullOrWhiteSpace(name)) + { + Result = false; + Msg = "The login can't be empty."; + } + else + { + Result = true; + Msg = string.Empty; + } + return Result; + } + internal static bool ValidateADUI(Session Ctx, string Ns, out string Msg) + { + bool Result = true; + if (!ValidateADDomainUI(Ctx, Ns, out Msg)) + Result = false; + else if (!ValidateADLoginUI(Ctx, Ns, out Msg)) + Result = false; + else if (!ValidatePasswordUI(Ctx, Ns, out Msg)) + Result = false; + return Result; + } + internal static bool ValidateDbNameUI(Session Ctx, out string Msg) + { + Msg = string.Empty; + var Result = true; + string DbName = Ctx["DB_DATABASE"]; + if (string.IsNullOrWhiteSpace(DbName)) + { + Result = false; + Msg = "The database name can't be empty."; + + } + return Result; + } + internal static void RecapListReset(Session Ctx) + { + Ctx["CUSTOM_INSTALL_TEXT"] = string.Empty; + } + internal static void RecapListAdd(Session Ctx, params string[] Msgs) + { + foreach (var Msg in Msgs) + AddTo(Ctx, "CUSTOM_INSTALL_TEXT", Msg); ; + } + + internal static string GetProperty(Session Ctx, string Property) + { + if (Ctx.CustomActionData.ContainsKey(Property)) + return Ctx[Property]; + else + return string.Empty; + } + + private static ActionResult ProcessInstall(Session Ctx, WiXInstallType InstallType) + { + IWiXSetup Install = null; + try + { + Ctx.AttachToSetupLog(); + switch (InstallType) + { + case WiXInstallType.InstallServer: + Install = ServerSetup.Create(Ctx.CustomActionData, SetupActions.Install); + break; + case WiXInstallType.RemoveServer: + Install = ServerSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall); + break; + case WiXInstallType.InstallEnterpriseServer: + Install = EServerSetup.Create(Ctx.CustomActionData, SetupActions.Install); + break; + case WiXInstallType.RemoveEnterpriseServer: + Install = EServerSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall); + break; + case WiXInstallType.InstallPortal: + Install = PortalSetup.Create(Ctx.CustomActionData, SetupActions.Install); + break; + case WiXInstallType.RemovePortal: + Install = PortalSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall); + break; + default: + throw new NotImplementedException(); + } + Install.Run(); + } + catch (WiXSetupException we) + { + Ctx.Log("Expected exception: " + we.ToString()); + return ActionResult.Failure; + } + catch (Exception ex) + { + Ctx.Log(ex.ToString()); + return ActionResult.Failure; + } + return ActionResult.Success; + } + [Conditional("DEBUG")] + private static void PopUpDebugger() + { + Debugger.Launch(); + } } + public static class SessionExtension + { + public static void AttachToSetupLog(this Session Ctx) + { + WiXSetup.InstallLogListener(new WiXLogListener(Ctx)); + WiXSetup.InstallLogListener(new InMemoryStringLogListener("WIX CA IN MEMORY")); + } + } + + internal enum WiXInstallType: byte + { + InstallServer, + InstallEnterpriseServer, + InstallPortal, + RemoveServer, + RemoveEnterpriseServer, + RemovePortal, + RemoveUpdate, + RestoreUpdate + } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj index b2211e38..59ae4596 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj @@ -32,10 +32,25 @@ 4 + + + + $(BaseIntermediateOutputPath)$(Configuration)\ + $(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\ + + + $(IntermediateOutputPath)$(AssemblyName).pdb;@(AddPdb) + + + + False + ..\..\Lib\Microsoft.Web.Administration.dll + + @@ -44,6 +59,12 @@ + + + + + + @@ -53,6 +74,10 @@ {3951C0EC-BD98-450E-B228-CDBE5BD4AD49} WebsitePanel.Setup + + {0E4A3F5B-0BB1-4F63-863D-7B0182B378CF} + WebsitePanel.Installer.Core + diff --git a/WebsitePanel/build-release.bat b/WebsitePanel/build-release.bat index 2ad25172..315aa852 100644 --- a/WebsitePanel/build-release.bat +++ b/WebsitePanel/build-release.bat @@ -1 +1 @@ -%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe build.xml /target:Build /p:BuildConfiguration=Release /p:Version="2.1.0" /p:FileVersion="2.1.0.1" /p:VersionLabel="2.1.0.1" /v:n /fileLogger /m \ No newline at end of file +%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe build.xml /target:Build /p:BuildConfiguration=Release /p:Version="2.1.0" /p:FileVersion="2.1.0.1" /p:VersionLabel="2.1.0.1" /v:n /fileLogger /m