This commit is contained in:
Alexander Trofimov 2015-05-05 16:00:20 +03:00
commit 2edbacf131
12 changed files with 359 additions and 142 deletions

View file

@ -215,7 +215,7 @@
<Condition Action="disable">DB_CONN_CORRECT="0"</Condition> <Condition Action="disable">DB_CONN_CORRECT="0"</Condition>
<Condition Action="enable">DB_CONN_CORRECT="1"</Condition> <Condition Action="enable">DB_CONN_CORRECT="1"</Condition>
</Control> </Control>
<Control Type="PushButton" Id ="CheckConnButton" X="160" Y="200" Width="64" Height="17" Text="Test connection" /> <Control Type="PushButton" Id ="CheckConnButton" X="150" Y="200" Width="74" Height="17" Text="Test connection" />
</Dialog> </Dialog>
<Dialog Id="ConnectionWarningDlg" Width="250" Height="85" Title="[ProductName] Setup" NoMinimize="yes"> <Dialog Id="ConnectionWarningDlg" Width="250" Height="85" Title="[ProductName] Setup" NoMinimize="yes">
<Control Id="Ok" Type="PushButton" X="184" Y="60" Width="56" Height="17" Text="Ok" Default="yes" Cancel="yes"/> <Control Id="Ok" Type="PushButton" X="184" Y="60" Width="56" Height="17" Text="Ok" Default="yes" Cancel="yes"/>
@ -563,17 +563,14 @@
<CustomAction Id="CA_DatabaseConnectionValidateUI" BinaryKey="Assembly_CA" DllEntry="DatabaseConnectionValidateUI" /> <CustomAction Id="CA_DatabaseConnectionValidateUI" BinaryKey="Assembly_CA" DllEntry="DatabaseConnectionValidateUI" />
<CustomAction Id="CA_RecapListUI" BinaryKey="Assembly_CA" DllEntry="RecapListUI" /> <CustomAction Id="CA_RecapListUI" BinaryKey="Assembly_CA" DllEntry="RecapListUI" />
<CustomAction Id="CA_SqlServerListUI" BinaryKey="Assembly_CA" DllEntry="SqlServerListUI" /> <CustomAction Id="CA_SqlServerListUI" BinaryKey="Assembly_CA" DllEntry="SqlServerListUI" />
<CustomAction Id="CA_DirectoryObjectPicker" BinaryKey="MsiExt.ActiveDirectory" DllEntry="DirectoryObjectPicker" /> <CustomAction Id="CA_DirectoryObjectPicker" BinaryKey="MsiExt.ActiveDirectory" DllEntry="DirectoryObjectPicker" />
<CustomAction Id="CA_SetSqlDmoListLocal" Property="SQLDMO_LIST_LOCAL" Value="(local)" Execute="immediate" /> <CustomAction Id="CA_SetSqlDmoListLocal" Property="SQLDMO_LIST_LOCAL" Value="(local)" Execute="immediate" />
<CustomAction Id="CA_SetSqlDmoListIndex" Property="SQLDMO_LIST_INDEX" Value="2" Execute="immediate" /> <CustomAction Id="CA_SetSqlDmoListIndex" Property="SQLDMO_LIST_INDEX" Value="2" Execute="immediate" />
<CustomAction Id="CA_SetSqlDmoListProperty" Property="SQLDMO_LIST_PROPERTY" Value="DB_SERVER" Execute="immediate" /> <CustomAction Id="CA_SetSqlDmoListProperty" Property="SQLDMO_LIST_PROPERTY" Value="DB_SERVER" Execute="immediate" />
<CustomAction Id="CA_SetSqlDmoListType" Property="SQLDMO_LIST_TYPE" Value="ComboBox" Execute="immediate" /> <CustomAction Id="CA_SetSqlDmoListType" Property="SQLDMO_LIST_TYPE" Value="ComboBox" Execute="immediate" />
<CustomAction Id="CA_SQLDMO_ListAvailableSQLServers" BinaryKey="MsiExt.DataSource" DllEntry="SQLDMO_ListAvailableSQLServers" /> <CustomAction Id="CA_SQLDMO_ListAvailableSQLServers" BinaryKey="MsiExt.DataSource" DllEntry="SQLDMO_ListAvailableSQLServers" />
<CustomAction Id="CA_SetEServerUrlUI" BinaryKey ="Assembly_CA" DllEntry="SetEServerUrlUI" /> <CustomAction Id="CA_SetEServerUrlUI" BinaryKey ="Assembly_CA" DllEntry="SetEServerUrlUI" />
<CustomAction Id="CA_InstallWebFeatures" BinaryKey="Assembly_CA" DllEntry="InstallWebFeatures" Impersonate="no" />
<!--Run corresponding install scripts.--> <!--Run corresponding install scripts.-->
<!--Server.--> <!--Server.-->
<CustomAction Id="CA_PropertyOnServerInstall" Property="CA_OnServerInstall" Value="ApplicationName=$(var.NAME);ComponentName=$(var.ServerTitle);ComponentCode=server;ComponentDescription=$(var.ServerDescription);Version=$(var.VERSION);InstallationFolder=[INSTALLSERVERFOLDER];InstallerFolder=[WEBSITEPANELDIR];Installer=[];InstallerType=[];InstallerPath=[];IISVersion=[];SetupXml=[];WebSiteIP=[PI_SERVER_IP];WebSitePort=[PI_SERVER_PORT];WebSiteDomain=[PI_SERVER_HOST];UserDomain=[PI_SERVER_DOMAIN];UserAccount=[PI_SERVER_LOGIN];UserPassword=[PI_SERVER_PASSWORD];ServerPassword=[SERVER_ACCESS_PASSWORD];EnterpriseServerUrl=[PI_ESERVER_URL];ServerAdminPassword=[SERVERADMIN_PASSWORD];DatabaseServer=[DB_SERVER];DatabaseName=[DB_DATABASE];DbServerAdmin=[DB_LOGIN];DbServerAdminPassword=[DB_PASSWORD];BaseDirectory=[WEBSITEPANELDIR];MODE_UP=[WIX_UPGRADE_DETECTED];MODE_RUP=[UPGRADINGPRODUCTCODE]" /> <CustomAction Id="CA_PropertyOnServerInstall" Property="CA_OnServerInstall" Value="ApplicationName=$(var.NAME);ComponentName=$(var.ServerTitle);ComponentCode=server;ComponentDescription=$(var.ServerDescription);Version=$(var.VERSION);InstallationFolder=[INSTALLSERVERFOLDER];InstallerFolder=[WEBSITEPANELDIR];Installer=[];InstallerType=[];InstallerPath=[];IISVersion=[];SetupXml=[];WebSiteIP=[PI_SERVER_IP];WebSitePort=[PI_SERVER_PORT];WebSiteDomain=[PI_SERVER_HOST];UserDomain=[PI_SERVER_DOMAIN];UserAccount=[PI_SERVER_LOGIN];UserPassword=[PI_SERVER_PASSWORD];ServerPassword=[SERVER_ACCESS_PASSWORD];EnterpriseServerUrl=[PI_ESERVER_URL];ServerAdminPassword=[SERVERADMIN_PASSWORD];DatabaseServer=[DB_SERVER];DatabaseName=[DB_DATABASE];DbServerAdmin=[DB_LOGIN];DbServerAdminPassword=[DB_PASSWORD];BaseDirectory=[WEBSITEPANELDIR];MODE_UP=[WIX_UPGRADE_DETECTED];MODE_RUP=[UPGRADINGPRODUCTCODE]" />
@ -595,6 +592,7 @@
<SetProperty Id="WEBSITEPANELDIR" After="AppSearch" Value="[WSP_ROOT]">WSP_ROOT</SetProperty> <SetProperty Id="WEBSITEPANELDIR" After="AppSearch" Value="[WSP_ROOT]">WSP_ROOT</SetProperty>
<!--Exe sequence.--> <!--Exe sequence.-->
<InstallExecuteSequence> <InstallExecuteSequence>
<Custom Action="CA_InstallWebFeatures" After="InstallValidate"><![CDATA[(&ServerFeature=3) OR (&EnterpriseServerFeature=3) OR (&PortalFeature=3) OR (&SchedulerServiceFeature=3) OR (&WDPortalFeature=3)]]></Custom>
<!--<Custom Action="CA_PropertyFinalizeInstall" After='InstallValidate'/> <!--<Custom Action="CA_PropertyFinalizeInstall" After='InstallValidate'/>
<Custom Action="CA_FinalizeUnInstall" After="InstallValidate">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom> <Custom Action="CA_FinalizeUnInstall" After="InstallValidate">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
<Custom Action="CA_FinalizeInstall" After="InstallFiles" >NOT Installed or REINSTALL</Custom>--> <Custom Action="CA_FinalizeInstall" After="InstallFiles" >NOT Installed or REINSTALL</Custom>-->
@ -614,6 +612,7 @@
<Custom Action="CA_OnPortalRemove" After="CA_PropertyOnPortalRemove"><![CDATA[(&PortalFeature=2) AND (!PortalFeature=3)]]></Custom> <Custom Action="CA_OnPortalRemove" After="CA_PropertyOnPortalRemove"><![CDATA[(&PortalFeature=2) AND (!PortalFeature=3)]]></Custom>
</InstallExecuteSequence> </InstallExecuteSequence>
<InstallUISequence> <InstallUISequence>
<Custom Action="CA_InstallWebFeatures" Before="CA_PrereqCheck" />
<Custom Action="CA_PrereqCheck" After ="CostInitialize" /> <Custom Action="CA_PrereqCheck" After ="CostInitialize" />
<Custom Action="CA_PrereqCheckUI" After ="CA_PrereqCheck" /> <Custom Action="CA_PrereqCheckUI" After ="CA_PrereqCheck" />
<Custom Action="CA_FillIpListUI" After="CostInitialize" /> <Custom Action="CA_FillIpListUI" After="CostInitialize" />

View file

@ -57,7 +57,7 @@ namespace WebsitePanel.Setup
/// </summary> /// </summary>
/// <param name="message">Error message.</param> /// <param name="message">Error message.</param>
/// <param name="ex">Exception.</param> /// <param name="ex">Exception.</param>
internal static void WriteError(string message, Exception ex) public static void WriteError(string message, Exception ex)
{ {
try try
{ {
@ -74,7 +74,7 @@ namespace WebsitePanel.Setup
/// </summary> /// </summary>
/// <param name="message">Error message.</param> /// <param name="message">Error message.</param>
/// <param name="ex">Exception.</param> /// <param name="ex">Exception.</param>
internal static void WriteError(string message) public static void WriteError(string message)
{ {
WriteError(message, null); WriteError(message, null);
} }
@ -83,7 +83,7 @@ namespace WebsitePanel.Setup
/// Write to log /// Write to log
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
internal static void Write(string message) public static void Write(string message)
{ {
try try
{ {
@ -98,7 +98,7 @@ namespace WebsitePanel.Setup
/// Write line to log /// Write line to log
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
internal static void WriteLine(string message) public static void WriteLine(string message)
{ {
try try
{ {
@ -112,7 +112,7 @@ namespace WebsitePanel.Setup
/// Write info message to log /// Write info message to log
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
internal static void WriteInfo(string message) public static void WriteInfo(string message)
{ {
try try
{ {
@ -126,7 +126,7 @@ namespace WebsitePanel.Setup
/// Write start message to log /// Write start message to log
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
internal static void WriteStart(string message) public static void WriteStart(string message)
{ {
try try
{ {
@ -141,7 +141,7 @@ namespace WebsitePanel.Setup
/// Write end message to log /// Write end message to log
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
internal static void WriteEnd(string message) public static void WriteEnd(string message)
{ {
try try
{ {

View file

@ -138,9 +138,9 @@ namespace WebsitePanel.Setup
var licPage = new LicenseAgreementPage(); var licPage = new LicenseAgreementPage();
var page1 = new ConfigurationCheckPage(); var page1 = new ConfigurationCheckPage();
// //
ConfigurationCheck check1 = new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement"); ConfigurationCheck check1 = new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement") { SetupVariables = setupVariables };
ConfigurationCheck check2 = new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement"); ConfigurationCheck check2 = new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement") { SetupVariables = setupVariables };
ConfigurationCheck check3 = new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement"); ConfigurationCheck check3 = new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement") { SetupVariables = setupVariables };
// //
page1.Checks.AddRange(new ConfigurationCheck[] { check1, check2, check3 }); page1.Checks.AddRange(new ConfigurationCheck[] { check1, check2, check3 });
// //

View file

@ -124,9 +124,9 @@ namespace WebsitePanel.Setup
var introPage = new IntroductionPage(); var introPage = new IntroductionPage();
var licPage = new LicenseAgreementPage(); var licPage = new LicenseAgreementPage();
var page1 = new ConfigurationCheckPage(); var page1 = new ConfigurationCheckPage();
ConfigurationCheck check1 = new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement"); ConfigurationCheck check1 = new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement") { SetupVariables = setupVariables };
ConfigurationCheck check2 = new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement"); ConfigurationCheck check2 = new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement") { SetupVariables = setupVariables };
ConfigurationCheck check3 = new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement"); ConfigurationCheck check3 = new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement") { SetupVariables = setupVariables };
page1.Checks.AddRange(new ConfigurationCheck[] { check1, check2, check3 }); page1.Checks.AddRange(new ConfigurationCheck[] { check1, check2, check3 });
var page2 = new InstallFolderPage(); var page2 = new InstallFolderPage();
var page3 = new WebPage(); var page3 = new WebPage();

View file

@ -44,107 +44,107 @@ namespace WebsitePanel.Setup
return InstallBase(obj, "1.0.1"); return InstallBase(obj, "1.0.1");
} }
internal static object InstallBase(object obj, string minimalInstallerVersion) internal static object InstallBase(object obj, string minimalInstallerVersion)
{ {
Hashtable args = Utils.GetSetupParameters(obj); Hashtable args = Utils.GetSetupParameters(obj);
//check CS version //check CS version
string shellVersion = Utils.GetStringSetupParameter(args, Global.Parameters.ShellVersion); string shellVersion = Utils.GetStringSetupParameter(args, Global.Parameters.ShellVersion);
var shellMode = Utils.GetStringSetupParameter(args, Global.Parameters.ShellMode); var shellMode = Utils.GetStringSetupParameter(args, Global.Parameters.ShellMode);
Version version = new Version(shellVersion); Version version = new Version(shellVersion);
// //
var setupVariables = new SetupVariables var setupVariables = new SetupVariables
{ {
SetupAction = SetupActions.Install, SetupAction = SetupActions.Install,
IISVersion = Global.IISVersion IISVersion = Global.IISVersion
}; };
// //
InitInstall(args, setupVariables); InitInstall(args, setupVariables);
//Unattended setup //Unattended setup
LoadSetupVariablesFromSetupXml(setupVariables.SetupXml, setupVariables); LoadSetupVariablesFromSetupXml(setupVariables.SetupXml, setupVariables);
// //
var sam = new ServerActionManager(setupVariables); var sam = new ServerActionManager(setupVariables);
// Prepare installation defaults // Prepare installation defaults
sam.PrepareDistributiveDefaults(); sam.PrepareDistributiveDefaults();
// Silent Installer Mode // Silent Installer Mode
if (shellMode.Equals(Global.SilentInstallerShell, StringComparison.OrdinalIgnoreCase)) if (shellMode.Equals(Global.SilentInstallerShell, StringComparison.OrdinalIgnoreCase))
{ {
if (version < new Version(minimalInstallerVersion)) if (version < new Version(minimalInstallerVersion))
{ {
Utils.ShowConsoleErrorMessage(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion); Utils.ShowConsoleErrorMessage(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion);
// //
return false; return false;
} }
try try
{ {
var success = true; var success = true;
// //
setupVariables.ServerPassword = Utils.GetStringSetupParameter(args, Global.Parameters.ServerPassword); setupVariables.ServerPassword = Utils.GetStringSetupParameter(args, Global.Parameters.ServerPassword);
// //
sam.ActionError += new EventHandler<ActionErrorEventArgs>((object sender, ActionErrorEventArgs e) => sam.ActionError += new EventHandler<ActionErrorEventArgs>((object sender, ActionErrorEventArgs e) =>
{ {
Utils.ShowConsoleErrorMessage(e.ErrorMessage); Utils.ShowConsoleErrorMessage(e.ErrorMessage);
// //
Log.WriteError(e.ErrorMessage); Log.WriteError(e.ErrorMessage);
// //
success = false; success = false;
}); });
// //
sam.Start(); sam.Start();
// //
return success; return success;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.WriteError("Failed to install the component", ex); Log.WriteError("Failed to install the component", ex);
// //
return false; return false;
} }
} }
else else
{ {
if (version < new Version(minimalInstallerVersion)) if (version < new Version(minimalInstallerVersion))
{ {
MessageBox.Show(String.Format(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion), "Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show(String.Format(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion), "Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// //
return DialogResult.Cancel; return DialogResult.Cancel;
} }
var form = new InstallerForm(); var form = new InstallerForm();
var wizard = form.Wizard; var wizard = form.Wizard;
wizard.SetupVariables = setupVariables; wizard.SetupVariables = setupVariables;
// //
wizard.ActionManager = sam; wizard.ActionManager = sam;
//create wizard pages //create wizard pages
var introPage = new IntroductionPage(); var introPage = new IntroductionPage();
var licPage = new LicenseAgreementPage(); var licPage = new LicenseAgreementPage();
// //
var page1 = new ConfigurationCheckPage(); var page1 = new ConfigurationCheckPage();
page1.Checks.AddRange(new ConfigurationCheck[] page1.Checks.AddRange(new ConfigurationCheck[]
{ {
new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement"), new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement"){ SetupVariables = setupVariables },
new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement"), new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement"){ SetupVariables = setupVariables },
new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement") new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement"){ SetupVariables = setupVariables }
}); });
// //
var page2 = new InstallFolderPage(); var page2 = new InstallFolderPage();
var page3 = new WebPage(); var page3 = new WebPage();
var page4 = new UserAccountPage(); var page4 = new UserAccountPage();
var page5 = new ServerPasswordPage(); var page5 = new ServerPasswordPage();
var page6 = new ExpressInstallPage2(); var page6 = new ExpressInstallPage2();
var page7 = new FinishPage(); var page7 = new FinishPage();
// //
wizard.Controls.AddRange(new Control[] { introPage, licPage, page1, page2, page3, page4, page5, page6, page7 }); wizard.Controls.AddRange(new Control[] { introPage, licPage, page1, page2, page3, page4, page5, page6, page7 });
wizard.LinkPages(); wizard.LinkPages();
wizard.SelectedPage = introPage; wizard.SelectedPage = introPage;
//show wizard //show wizard
IWin32Window owner = args["ParentForm"] as IWin32Window; IWin32Window owner = args["ParentForm"] as IWin32Window;
return form.ShowModal(owner); return form.ShowModal(owner);
} }
} }
public static object Uninstall(object obj) public static object Uninstall(object obj)
{ {

View file

@ -250,9 +250,9 @@ namespace WebsitePanel.Setup
var page2 = new ConfigurationCheckPage(); var page2 = new ConfigurationCheckPage();
// Setup prerequisites validation // Setup prerequisites validation
page2.Checks.AddRange(new ConfigurationCheck[] { page2.Checks.AddRange(new ConfigurationCheck[] {
new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement"), new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement"){ SetupVariables = serverSetup },
new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement"), new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement"){ SetupVariables = serverSetup },
new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement"), new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement"){ SetupVariables = serverSetup },
// Validate Server installation prerequisites // Validate Server installation prerequisites
new ConfigurationCheck(CheckTypes.WPServer, "WebsitePanel Server Requirement") { SetupVariables = serverSetup }, new ConfigurationCheck(CheckTypes.WPServer, "WebsitePanel Server Requirement") { SetupVariables = serverSetup },
// Validate EnterpriseServer installation prerequisites // Validate EnterpriseServer installation prerequisites

View file

@ -601,16 +601,29 @@ namespace WebsitePanel.Setup
private static bool IsAspNetRoleServiceInstalled() private static bool IsAspNetRoleServiceInstalled()
{ {
RegistryKey regkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\InetStp\\Components"); return GetIsWebFeaturesInstalled();
if (regkey == null)
return false;
int value = (int)regkey.GetValue("ASPNET", 0);
if (value != 1)
value = (int)regkey.GetValue("ASPNET45", 0);
return value == 1;
} }
private static bool GetIsWebFeaturesInstalled()
{ // See WebsitePanel.Installer\Sources\WebsitePanel.WIXInstaller\Common\Tool.cs
bool Result = false;
var LMKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
Result |= CheckAspNetRegValue(LMKey);
LMKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
Result |= CheckAspNetRegValue(LMKey);
return Result;
}
private static bool CheckAspNetRegValue(RegistryKey BaseKey)
{
var WebComponentsKey = "SOFTWARE\\Microsoft\\InetStp\\Components";
var AspNet = "ASPNET";
var AspNet45 = "ASPNET45";
RegistryKey Key = BaseKey.OpenSubKey(WebComponentsKey);
if (Key == null)
return false;
var Value = int.Parse(Key.GetValue(AspNet, 0).ToString());
if (Value != 1)
Value = int.Parse(Key.GetValue(AspNet45, 0).ToString());
return Value == 1;
}
} }
} }

View file

@ -1,14 +1,16 @@
using Microsoft.Deployment.WindowsInstaller; using System;
using System; using System.Diagnostics;
using System.Collections.Generic; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using Microsoft.Deployment.WindowsInstaller;
using Microsoft.Win32;
using WebsitePanel.Setup; using WebsitePanel.Setup;
namespace WebsitePanel.WIXInstaller.Common namespace WebsitePanel.WIXInstaller.Common
{ {
internal static class Tool internal static class Tool
{ {
public const int MINIMUM_WEBSERVER_MAJOR_VERSION = 6;
public static SetupVariables GetSetupVars(Session Ctx) public static SetupVariables GetSetupVars(Session Ctx)
{ {
return new SetupVariables return new SetupVariables
@ -17,20 +19,159 @@ namespace WebsitePanel.WIXInstaller.Common
IISVersion = Global.IISVersion IISVersion = Global.IISVersion
}; };
} }
public static Version GetWebServerVersion()
public static void FillServerVariables(SetupVariables Vars)
{ {
var WebServerKey = "SOFTWARE\\Microsoft\\InetStp";
RegistryKey Key = Registry.LocalMachine.OpenSubKey(WebServerKey);
if (Key == null)
return new Version(0,0);
var Major = int.Parse(Key.GetValue("MajorVersion", 0).ToString());
var Minor = int.Parse(Key.GetValue("MinorVersion", 0).ToString());
return new Version(Major, Minor);
} }
public static bool GetIsWebRoleInstalled()
public static void FillEServerVariables(SetupVariables Vars)
{ {
var WebServer = GetWebServerVersion();
return WebServer.Major >= Tool.MINIMUM_WEBSERVER_MAJOR_VERSION;
} }
public static bool GetIsWebFeaturesInstalled()
public static void FillPortalVariables(SetupVariables Vars)
{ {
bool Result = false;
var LMKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
Result |= CheckAspNetRegValue(LMKey);
LMKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
Result |= CheckAspNetRegValue(LMKey);
return Result;
}
public static bool CheckAspNetRegValue(RegistryKey BaseKey)
{
var WebComponentsKey = "SOFTWARE\\Microsoft\\InetStp\\Components";
var AspNet = "ASPNET";
var AspNet45 = "ASPNET45";
RegistryKey Key = BaseKey.OpenSubKey(WebComponentsKey);
if (Key == null)
return false;
var Value = int.Parse(Key.GetValue(AspNet, 0).ToString());
if (Value != 1)
Value = int.Parse(Key.GetValue(AspNet45, 0).ToString());
return Value == 1;
}
public static bool InstallWebRole(out string Msg)
{
Msg = string.Empty;
var OSV = Global.OSVersion;
switch (OSV)
{
case OS.WindowsVersion.WindowsServer2008:
{
var Features = new[]
{
"Web-Server"
};
Msg = InstallWebViaServerManagerCmd(Features);
}
break;
case OS.WindowsVersion.WindowsServer2008R2:
case OS.WindowsVersion.WindowsServer2012:
case OS.WindowsVersion.WindowsServer2012R2:
case OS.WindowsVersion.Windows7:
case OS.WindowsVersion.Windows8:
{
var Features = new[]
{
"IIS-WebServer",
"IIS-WebServerRole",
"IIS-CommonHttpFeatures",
"IIS-DefaultDocument",
"IIS-ISAPIExtensions",
"IIS-ISAPIFilter",
"IIS-ManagementConsole",
"IIS-NetFxExtensibility",
"IIS-RequestFiltering",
"IIS-Security",
"IIS-StaticContent"
};
Msg = InstallWebViaDism(Features);
}
break;
default:
return false;
}
return true;
}
public static bool InstallWebFeatures(out string Msg)
{
Msg = string.Empty;
var OSV = Global.OSVersion;
switch (OSV)
{
case OS.WindowsVersion.WindowsServer2008:
{
var Features = new[]
{
"Web-Asp-Net"
};
Msg += InstallWebViaServerManagerCmd(Features);
Msg += PrepareAspNet();
}
break;
case OS.WindowsVersion.WindowsServer2008R2:
case OS.WindowsVersion.WindowsServer2012:
case OS.WindowsVersion.WindowsServer2012R2:
case OS.WindowsVersion.Windows7:
case OS.WindowsVersion.Windows8:
{
var Features = new[]
{
"IIS-ApplicationDevelopment",
"IIS-ASPNET",
"IIS-ASPNET45"
};
Msg = InstallWebViaDism(Features);
}
break;
default:
return false;
}
return true;
}
public static string PrepareAspNet()
{
var Cmd = string.Format(@"Microsoft.NET\Framework{0}\v4.0.30319\aspnet_regiis.exe", Environment.Is64BitOperatingSystem ? "64" : "" );
return RunTool(Path.Combine(OS.GetWindowsDirectory(), Cmd), "-i -enable");
}
private static string InstallWebViaDism(params string[] Features)
{
var Params = string.Format("/NoRestart /Online /Enable-Feature {0}",
string.Join(" ", Features.Select(
Feature => string.Format("/FeatureName:{0} /All", Feature)
)));
return RunTool(Path.Combine(OS.GetWindowsDirectory(), @"SysNative\dism.exe"), Params);
}
private static string InstallWebViaServerManagerCmd(params string[] Features)
{
var Params = string.Format("-install {0}",
string.Join(" ", Features)
);
return RunTool(Path.Combine(OS.GetWindowsDirectory(), @"SysNative\servermanagercmd.exe"), Params);
}
private static string RunTool(string Name, string Params)
{
var ToolProcessInfo = new ProcessStartInfo
{
FileName = Name,
Arguments = Params,
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden
};
using (var ToolProcess = Process.Start(ToolProcessInfo))
{
var Result = ToolProcess.StandardOutput.ReadToEnd();
ToolProcess.WaitForExit();
return Result;
}
} }
} }
} }

View file

@ -53,6 +53,45 @@ namespace WebsitePanel.WIXInstaller
public const string CustomDataDelimiter = "-=del=-"; public const string CustomDataDelimiter = "-=del=-";
#region CustomActions #region CustomActions
[CustomAction]
public static ActionResult InstallWebFeatures(Session session)
{
var Msg = string.Empty;
var Ctx = session;
Ctx.AttachToSetupLog();
var Result = ActionResult.Success;
try
{
Log.WriteStart("InstallWebFeatures");
if(Tool.GetIsWebRoleInstalled())
{
if (!Tool.GetIsWebFeaturesInstalled())
{
Log.WriteInfo("InstallWebFeatures: ASP.NET.");
Tool.InstallWebFeatures(out Msg);
}
}
else
{
var Tmp = string.Empty;
Log.WriteInfo("InstallWebFeatures: IIS and ASP.NET.");
Tool.InstallWebRole(out Tmp);
Msg += Tmp;
Tool.InstallWebFeatures(out Tmp);
Msg += Tmp;
}
Log.WriteInfo("InstallWebFeatures: done.");
}
catch(Exception ex)
{
Log.WriteError(string.Format("InstallWebFeatures: fail - {0}.", ex.ToString()));
Result = ActionResult.Failure;
}
if(!string.IsNullOrWhiteSpace(Msg))
Log.WriteInfo(string.Format("InstallWebFeatures Tool Log: {0}.", Msg));
Log.WriteEnd("InstallWebFeatures");
return Result;
}
// Install. // Install.
[CustomAction] [CustomAction]
public static ActionResult OnServerInstall(Session session) public static ActionResult OnServerInstall(Session session)

View file

@ -5274,6 +5274,21 @@
<data name="ServiceItemType.VMInfo" xml:space="preserve"> <data name="ServiceItemType.VMInfo" xml:space="preserve">
<value>Virtual Machine (Private Cloud)</value> <value>Virtual Machine (Private Cloud)</value>
</data> </data>
<data name="UserItemType.Username" xml:space="preserve">
<value>Username</value>
</data>
<data name="UserItemType.Email" xml:space="preserve">
<value>E-mail</value>
</data>
<data name="UserItemType.CompanyName" xml:space="preserve">
<value>Company Name</value>
</data>
<data name="UserItemType.FullName" xml:space="preserve">
<value>Full Name</value>
</data>
<data name="UserItemType.ExchangeAccount" xml:space="preserve">
<value>Exchange Account</value>
</data>
<data name="Error.WEB_PUB_DISABLE" xml:space="preserve"> <data name="Error.WEB_PUB_DISABLE" xml:space="preserve">
<value>Could not disable access to Web Publishing feature for the account specified</value> <value>Could not disable access to Web Publishing feature for the account specified</value>
</data> </data>

View file

@ -70,7 +70,7 @@
<a href="javascript: void(0)" onclick="CPopupDialog('mydialog',event)">Type</a> <a href="javascript: void(0)" onclick="CPopupDialog('mydialog',event)">Type</a>
</HeaderTemplate> </HeaderTemplate>
<ItemTemplate> <ItemTemplate>
<%# Eval("ColumnType") %> <%# GetTypeDisplayName((string)Eval("ColumnType")) %>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<asp:TemplateField SortExpression="TextSearch" HeaderText="gvText" HeaderStyle-Wrap="false"> <asp:TemplateField SortExpression="TextSearch" HeaderText="gvText" HeaderStyle-Wrap="false">
@ -80,9 +80,11 @@
</asp:hyperlink> </asp:hyperlink>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<asp:BoundField DataField="FullType" HtmlEncode="false" SortExpression="FullType" HeaderText="gvFullType"> <asp:TemplateField SortExpression="FullType" HeaderText="gvFullType" HeaderStyle-Wrap="false">
<HeaderStyle Wrap="false" /> <ItemTemplate>
</asp:BoundField> <%# GetTypeDisplayName((string)Eval("FullType")) %>
</ItemTemplate>
</asp:TemplateField>
</Columns> </Columns>
</asp:GridView> </asp:GridView>

View file

@ -6,6 +6,7 @@ using System.Web.UI;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using System.Web.Script.Serialization; using System.Web.Script.Serialization;
using WebsitePanel.WebPortal; using WebsitePanel.WebPortal;
using System.Xml;
namespace WebsitePanel.Portal namespace WebsitePanel.Portal
{ {
@ -48,6 +49,13 @@ namespace WebsitePanel.Portal
} }
} }
protected string GetTypeDisplayName(string type)
{
return GetSharedLocalizedString("ServiceItemType." + type)
?? GetSharedLocalizedString("UserItemType." + type)
?? type;
}
public string GetItemPageUrl(string fullType, string itemType, int itemId, int spaceId, int accountId) public string GetItemPageUrl(string fullType, string itemType, int itemId, int spaceId, int accountId)
{ {
string res = ""; string res = "";