WiX installer fixes.

This commit is contained in:
McMak 2015-05-25 19:43:56 +03:00
parent 276a106dc9
commit 6ec738ae6e
10 changed files with 247 additions and 58096 deletions

View file

@ -9,6 +9,4 @@
<?define PortalTitle="Portal"?> <?define PortalTitle="Portal"?>
<?define PortalDescription="WebsitePanel Portal is a control panel itself with user interface which allows managing user accounts, hosting spaces, web sites, FTP accounts, files, etc."?> <?define PortalDescription="WebsitePanel Portal is a control panel itself with user interface which allows managing user accounts, hosting spaces, web sites, FTP accounts, files, etc."?>
<?define VERSION="$(var.Version)"?> <?define VERSION="$(var.Version)"?>
<?define sql_release_version = "$(var.Version)"?> <!--N'${release.version}'-->
<?define sql_build_date = "$(var.BuildDate)"?> <!-- '${release.date}T00:00:00' - ISO 8601 Format (YYYY-MM-DDTHH:MM:SS) -->
</Include> </Include>

View file

@ -477,8 +477,8 @@
<Binary Id="bannrbmp" SourceFile="bannrbmp.bmp" /> <Binary Id="bannrbmp" SourceFile="bannrbmp.bmp" />
<Binary Id="passmark" SourceFile="passmark.ico" /> <Binary Id="passmark" SourceFile="passmark.ico" />
<Binary Id="failmark" SourceFile="failmark.ico" /> <Binary Id="failmark" SourceFile="failmark.ico" />
<Binary Id="InstallDB" SourceFile="$(var.PROJECTPATH)\Database\wix_install_db.sql" /> <Binary Id="InstallDB" SourceFile="$(var.PROJECTPATH)\Deploy\$(var.BUILD)\Database\wix_install_db.sql" />
<Binary Id="UpdateDB" SourceFile="$(var.PROJECTPATH)\Database\wix_update_db.sql" /> <Binary Id="UpdateDB" SourceFile="$(var.PROJECTPATH)\Deploy\$(var.BUILD)\Database\wix_update_db.sql" />
<WixVariable Id="WixUIBannerBmp" Value="bannrbmp.bmp" /> <WixVariable Id="WixUIBannerBmp" Value="bannrbmp.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="dlgbmp.bmp" /> <WixVariable Id="WixUIDialogBmp" Value="dlgbmp.bmp" />
<WixVariable Id="WixUILicenseRtf" Value="License.rtf" /> <WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
@ -643,13 +643,13 @@
<InstallExecuteSequence> <InstallExecuteSequence>
<!--Preinstall.--> <!--Preinstall.-->
<Custom Action="CA_InstallWebFeatures" Before="CostInitialize"><![CDATA[(&ServerFeature=3) OR (&EnterpriseServerFeature=3) OR (&PortalFeature=3) OR (&SchedulerServiceFeature=3) OR (&WDPortalFeature=3)]]></Custom> <Custom Action="CA_InstallWebFeatures" Before="CostInitialize"><![CDATA[(&ServerFeature=3) OR (&EnterpriseServerFeature=3) OR (&PortalFeature=3) OR (&SchedulerServiceFeature=3) OR (&WDPortalFeature=3)]]></Custom>
<!--Preparation when "old to new installer update".--> <!--Preparation when "old to new installer update". Also disabled in Maintenance mode.-->
<Custom Action="CA_PropertyOnServerPrepare" Before="InstallFiles"><![CDATA[COMPFOUND_SERVER=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE]]></Custom> <Custom Action="CA_PropertyOnServerPrepare" Before="RemoveFiles"><![CDATA[COMPFOUND_SERVER=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE AND NOT(&ServerFeature=-1 AND !ServerFeature=3)]]></Custom>
<Custom Action="CA_OnServerPrepare" After="CA_PropertyOnServerPrepare"><![CDATA[COMPFOUND_SERVER=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE]]></Custom> <Custom Action="CA_OnServerPrepare" After="CA_PropertyOnServerPrepare"><![CDATA[COMPFOUND_SERVER=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE AND NOT(&ServerFeature=-1 AND !ServerFeature=3)]]></Custom>
<Custom Action="CA_PropertyOnEServerPrepare" Before="InstallFiles"><![CDATA[COMPFOUND_ESERVER=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE]]></Custom> <Custom Action="CA_PropertyOnEServerPrepare" Before="RemoveFiles"><![CDATA[COMPFOUND_ESERVER=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE AND NOT (&EnterpriseServerFeature=-1 AND !EnterpriseServerFeature=3)]]></Custom>
<Custom Action="CA_OnEServerPrepare" After="CA_PropertyOnEServerPrepare"><![CDATA[COMPFOUND_ESERVER=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE]]></Custom> <Custom Action="CA_OnEServerPrepare" After="CA_PropertyOnEServerPrepare"><![CDATA[COMPFOUND_ESERVER=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE AND NOT (&EnterpriseServerFeature=-1 AND !EnterpriseServerFeature=3)]]></Custom>
<Custom Action="CA_PropertyOnPortalPrepare" Before="InstallFiles"><![CDATA[COMPFOUND_PORTAL=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE]]></Custom> <Custom Action="CA_PropertyOnPortalPrepare" Before="RemoveFiles"><![CDATA[COMPFOUND_PORTAL=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE AND NOT (&PortalFeature=-1 AND !PortalFeature=3)]]></Custom>
<Custom Action="CA_OnPortalPrepare" After="CA_PropertyOnPortalPrepare"><![CDATA[COMPFOUND_PORTAL=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE]]></Custom> <Custom Action="CA_OnPortalPrepare" After="CA_PropertyOnPortalPrepare"><![CDATA[COMPFOUND_PORTAL=1 AND NOT WIX_UPGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE AND NOT (&PortalFeature=-1 AND !PortalFeature=3)]]></Custom>
<!--First Install. [Installed] property not used here because we distinguish per feature basis.--> <!--First Install. [Installed] property not used here because we distinguish per feature basis.-->
<Custom Action="CA_PropertyOnServerInstall" After="InstallValidate"><![CDATA[(&ServerFeature=3) AND NOT(!ServerFeature=3)]]></Custom> <Custom Action="CA_PropertyOnServerInstall" After="InstallValidate"><![CDATA[(&ServerFeature=3) AND NOT(!ServerFeature=3)]]></Custom>
<Custom Action="CA_OnServerInstall" After="InstallFiles"><![CDATA[(&ServerFeature=3) AND NOT(!ServerFeature=3)]]></Custom> <Custom Action="CA_OnServerInstall" After="InstallFiles"><![CDATA[(&ServerFeature=3) AND NOT(!ServerFeature=3)]]></Custom>
@ -713,12 +713,7 @@
Server="[DB_SERVER]" Server="[DB_SERVER]"
Database="[DB_DATABASE]" Database="[DB_DATABASE]"
User="SqlUpdateUser"> User="SqlUpdateUser">
<sql:SqlString Id="SqlVersionUpdateSql" SQL="IF NOT EXISTS (SELECT * FROM dbo.Versions WHERE DatabaseVersion = '$(var.sql_release_version)') <sql:SqlScript Id="SqlUpdateScriptSql" BinaryKey="UpdateDB" Sequence="2"
BEGIN
INSERT dbo.Versions (DatabaseVersion, BuildDate) VALUES ('$(var.sql_release_version)', '$(var.sql_build_date)')
END"
Sequence="2" ContinueOnError="no" ExecuteOnInstall="yes" ExecuteOnReinstall="yes" ExecuteOnUninstall="no"/>
<sql:SqlScript Id="SqlUpdateScriptSql" BinaryKey="UpdateDB" Sequence="3"
ContinueOnError="no" ExecuteOnInstall="yes" ExecuteOnReinstall="yes" ExecuteOnUninstall="no"/> ContinueOnError="no" ExecuteOnInstall="yes" ExecuteOnReinstall="yes" ExecuteOnUninstall="no"/>
</sql:SqlDatabase> </sql:SqlDatabase>
</Component> </Component>
@ -739,12 +734,7 @@
DropOnInstall="no" DropOnReinstall="no" DropOnUninstall="no" DropOnInstall="no" DropOnReinstall="no" DropOnUninstall="no"
Server="[DB_SERVER]" Server="[DB_SERVER]"
Database="[DB_DATABASE]"> Database="[DB_DATABASE]">
<sql:SqlString Id="SqlVersionUpdateWin" SQL="IF NOT EXISTS (SELECT * FROM dbo.Versions WHERE DatabaseVersion = '$(var.sql_release_version)') <sql:SqlScript Id="SqlUpdateScriptWin" BinaryKey="UpdateDB" Sequence="11"
BEGIN
INSERT dbo.Versions (DatabaseVersion, BuildDate) VALUES ('$(var.sql_release_version)', '$(var.sql_build_date)')
END"
Sequence="11" ContinueOnError="no" ExecuteOnInstall="yes" ExecuteOnReinstall="yes" ExecuteOnUninstall="no"/>
<sql:SqlScript Id="SqlUpdateScriptWin" BinaryKey="UpdateDB" Sequence="12"
ContinueOnError="no" ExecuteOnInstall="yes" ExecuteOnReinstall="yes" ExecuteOnUninstall="no" /> ContinueOnError="no" ExecuteOnInstall="yes" ExecuteOnReinstall="yes" ExecuteOnUninstall="no" />
</sql:SqlDatabase> </sql:SqlDatabase>
</Component> </Component>
@ -759,6 +749,8 @@
<RegistryValue Root='HKLM' Key='SOFTWARE\[ProductName]' <RegistryValue Root='HKLM' Key='SOFTWARE\[ProductName]'
Name='Base' Value='[WSP_INSTALL_DIR]' Name='Base' Value='[WSP_INSTALL_DIR]'
Type='string' /> Type='string' />
<RemoveFolder Id='CleanUpWSP' On='uninstall'/>
</Component> </Component>
</ComponentGroup> </ComponentGroup>
</Fragment> </Fragment>

View file

@ -14,7 +14,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\</OutputPath> <OutputPath>bin\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath> <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;BUILD=debug;Version=$(Version);BuildDate=$(ReleaseDate)</DefineConstants> <DefineConstants>Debug;BUILD=debug;Version=$(Version)</DefineConstants>
<SuppressValidation>False</SuppressValidation> <SuppressValidation>False</SuppressValidation>
<SuppressIces> <SuppressIces>
</SuppressIces> </SuppressIces>
@ -26,7 +26,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath> <OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath> <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>BUILD=release;Version=$(Version);BuildDate=$(ReleaseDate)</DefineConstants> <DefineConstants>BUILD=release;Version=$(Version)</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CustomVerifyReadyDlg.wxs" /> <Compile Include="CustomVerifyReadyDlg.wxs" />
@ -46,10 +46,6 @@
<HintPath>..\..\..\tools\WIX\WixUIExtension.dll</HintPath> <HintPath>..\..\..\tools\WIX\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name> <Name>WixUIExtension</Name>
</WixExtension> </WixExtension>
<WixExtension Include="WixIIsExtension">
<HintPath>..\..\..\tools\WIX\WixIIsExtension.dll</HintPath>
<Name>WixIIsExtension</Name>
</WixExtension>
<WixExtension Include="WixSqlExtension"> <WixExtension Include="WixSqlExtension">
<HintPath>..\..\..\tools\WIX\WixSqlExtension.dll</HintPath> <HintPath>..\..\..\tools\WIX\WixSqlExtension.dll</HintPath>
<Name>WixSqlExtension</Name> <Name>WixSqlExtension</Name>

View file

@ -134,22 +134,18 @@ Global
{24A4C231-73A9-4F03-ABAD-9A8FE5324495}.Release|x86.Build.0 = 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|Any CPU.ActiveCfg = Debug|x86
{3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|Mixed Platforms.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.ActiveCfg = Debug|x86
{3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|x86.Build.0 = 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|Any CPU.ActiveCfg = Release|x86
{3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|Mixed Platforms.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.ActiveCfg = Release|x86
{3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|x86.Build.0 = 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|Any CPU.ActiveCfg = Debug|x86
{978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|Mixed Platforms.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.ActiveCfg = Debug|x86
{978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|x86.Build.0 = 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|Any CPU.ActiveCfg = Release|x86
{978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|Mixed Platforms.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.ActiveCfg = Release|x86
{978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|x86.Build.0 = Release|x86 {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|x86.Build.0 = Release|x86
EndGlobalSection EndGlobalSection

View file

@ -777,28 +777,19 @@ namespace WebsitePanel.Setup.Actions
try try
{ {
Begin(LogStartInstallMessage); Begin(LogStartInstallMessage);
//
Log.WriteStart("Updating configuration file (server password)"); Log.WriteStart("Updating configuration file (server password)");
Log.WriteInfo(String.Format("Server password is: '{0}'", vars.ServerPassword)); Log.WriteInfo(String.Format("Server password is: '{0}'", vars.ServerPassword));
Log.WriteInfo("Single quotes are added for clarity purposes"); Log.WriteInfo("Single quotes are added for clarity purposes");
//
string file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile); string file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile);
string hash = Utils.ComputeSHA1(vars.ServerPassword); string hash = Utils.ComputeSHA1(vars.ServerPassword);
// load file var XmlDoc = new XmlDocument();
string content = string.Empty; XmlDoc.Load(file);
using (StreamReader reader = new StreamReader(file)) var Node = XmlDoc.SelectSingleNode("configuration/websitepanel.server/security/password") as XmlElement;
{ if (Node == null)
content = reader.ReadToEnd(); throw new Exception("Unable to set a server access password. Check structure of configuration file.");
} else
Node.SetAttribute("value", hash);
// expand variables XmlDoc.Save(file);
content = Utils.ReplaceScriptVariable(content, "installer.server.password", hash);
// save file
using (StreamWriter writer = new StreamWriter(file))
{
writer.Write(content);
}
} }
catch (Exception ex) catch (Exception ex)
{ {

View file

@ -135,6 +135,7 @@ namespace WebsitePanel.Setup.Internal
//Dst.IISVersion = Utils.GetVersionSetupParameter(Hash, "IISVersion"); //Dst.IISVersion = Utils.GetVersionSetupParameter(Hash, "IISVersion");
Dst.SetupXml = Utils.GetStringSetupParameter(Hash, "SetupXml"); Dst.SetupXml = Utils.GetStringSetupParameter(Hash, "SetupXml");
Dst.ServerPassword = Utils.GetStringSetupParameter(Hash, Global.Parameters.ServerPassword); Dst.ServerPassword = Utils.GetStringSetupParameter(Hash, Global.Parameters.ServerPassword);
Dst.UpdateServerPassword = true;
Dst.WebSiteIP = Utils.GetStringSetupParameter(Hash, Global.Parameters.WebSiteIP); Dst.WebSiteIP = Utils.GetStringSetupParameter(Hash, Global.Parameters.WebSiteIP);
Dst.WebSitePort = Utils.GetStringSetupParameter(Hash, Global.Parameters.WebSitePort); Dst.WebSitePort = Utils.GetStringSetupParameter(Hash, Global.Parameters.WebSitePort);
@ -2191,6 +2192,8 @@ namespace WebsitePanel.Setup.Internal
Log.WriteEnd(Msg); Log.WriteEnd(Msg);
InstallLog.AppendLine(Msg); InstallLog.AppendLine(Msg);
} }
else
{
try try
{ {
string domain = Context.UserDomain; string domain = Context.UserDomain;
@ -2224,6 +2227,7 @@ namespace WebsitePanel.Setup.Internal
InstallLog.AppendLine(string.Format("- Failed to register \"{0}\" windows service ", service)); InstallLog.AppendLine(string.Format("- Failed to register \"{0}\" windows service ", service));
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
if (Utils.IsThreadAbortException(ex)) if (Utils.IsThreadAbortException(ex))
@ -3213,7 +3217,7 @@ namespace WebsitePanel.Setup.Internal
return; return;
string path = Path.Combine(Context.InstallationFolder, Context.ConfigurationFile); string path = Path.Combine(Context.InstallationFolder, Context.ConfigurationFile);
string hash = Context.ServerPassword; string hash = Utils.ComputeSHA1(Context.ServerPassword);
if (!File.Exists(path)) if (!File.Exists(path))
{ {
@ -4429,6 +4433,7 @@ namespace WebsitePanel.Setup.Internal
break; break;
case ModeExtension.Backup: case ModeExtension.Backup:
Script = new BackupScript(Context); Script = new BackupScript(Context);
Script.Actions.Add(new InstallAction(ActionTypes.StopWindowsService));
break; break;
default: default:
throw new NotImplementedException("Uninstall " + ModeExtension.ToString()); throw new NotImplementedException("Uninstall " + ModeExtension.ToString());

View file

@ -28,7 +28,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.Configuration.Install;
using System.Data; using System.Data;
using System.Data.Sql; using System.Data.Sql;
using System.Data.SqlClient; using System.Data.SqlClient;
@ -37,10 +36,12 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Net.Sockets; using System.Net.Sockets;
using System.ServiceProcess; using System.Text;
using System.Text.RegularExpressions; using System.Threading;
using System.Xml; using System.Threading.Tasks;
using Microsoft.Deployment.WindowsInstaller; using Microsoft.Deployment.WindowsInstaller;
using WebsitePanel.Setup; using WebsitePanel.Setup;
using WebsitePanel.Setup.Internal; using WebsitePanel.Setup.Internal;
using WebsitePanel.WIXInstaller.Common; using WebsitePanel.WIXInstaller.Common;
@ -92,6 +93,7 @@ namespace WebsitePanel.WIXInstaller
[CustomAction] [CustomAction]
public static ActionResult MaintenanceServer(Session session) public static ActionResult MaintenanceServer(Session session)
{ {
PopUpDebugger();
var Result = ActionResult.Success; var Result = ActionResult.Success;
Log.WriteStart("MaintenanceServer"); Log.WriteStart("MaintenanceServer");
Result = ProcessInstall(session, WiXInstallType.MaintenanceServer); Result = ProcessInstall(session, WiXInstallType.MaintenanceServer);
@ -101,6 +103,7 @@ namespace WebsitePanel.WIXInstaller
[CustomAction] [CustomAction]
public static ActionResult MaintenanceEServer(Session session) public static ActionResult MaintenanceEServer(Session session)
{ {
PopUpDebugger();
var Result = ActionResult.Success; var Result = ActionResult.Success;
Log.WriteStart("MaintenanceEServer"); Log.WriteStart("MaintenanceEServer");
Result = ProcessInstall(session, WiXInstallType.MaintenanceEnterpriseServer); Result = ProcessInstall(session, WiXInstallType.MaintenanceEnterpriseServer);
@ -110,6 +113,7 @@ namespace WebsitePanel.WIXInstaller
[CustomAction] [CustomAction]
public static ActionResult MaintenancePortal(Session session) public static ActionResult MaintenancePortal(Session session)
{ {
PopUpDebugger();
var Result = ActionResult.Success; var Result = ActionResult.Success;
Log.WriteStart("MaintenancePortal"); Log.WriteStart("MaintenancePortal");
Result = ProcessInstall(session, WiXInstallType.MaintenancePortal); Result = ProcessInstall(session, WiXInstallType.MaintenancePortal);
@ -160,6 +164,13 @@ namespace WebsitePanel.WIXInstaller
} }
return null; return null;
}; };
Action<Session, SetupVariables> VersionGuard = (Session SesCtx, SetupVariables CtxVars) =>
{
var Current = SesCtx["ProductVersion"];
var Found = string.IsNullOrWhiteSpace(CtxVars.Version) ? "0.0.0" : CtxVars.Version;
if ((new Version(Found) >= new Version(Current)) && !CtxVars.InstallerType.ToLowerInvariant().Equals("msi"))
throw new InvalidOperationException("New version must be reater than previous always.");
};
var Ctx = session; var Ctx = session;
Ctx.AttachToSetupLog(); Ctx.AttachToSetupLog();
@ -175,6 +186,8 @@ namespace WebsitePanel.WIXInstaller
select Path.Combine(Drive.RootDirectory.FullName, Global.DefaultProductName)); select Path.Combine(Drive.RootDirectory.FullName, Global.DefaultProductName));
var CfgPath = FindMainConfig(DirList); var CfgPath = FindMainConfig(DirList);
if (!string.IsNullOrWhiteSpace(CfgPath)) if (!string.IsNullOrWhiteSpace(CfgPath))
{
try
{ {
var EServerUrl = string.Empty; var EServerUrl = string.Empty;
AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = CfgPath }); AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = CfgPath });
@ -183,6 +196,7 @@ namespace WebsitePanel.WIXInstaller
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId)) if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
{ {
AppConfig.LoadComponentSettings(CtxVars); AppConfig.LoadComponentSettings(CtxVars);
VersionGuard(Ctx, CtxVars);
SetProperty(Ctx, "COMPFOUND_SERVER_ID", CtxVars.ComponentId); SetProperty(Ctx, "COMPFOUND_SERVER_ID", CtxVars.ComponentId);
SetProperty(Ctx, "COMPFOUND_SERVER_MAIN_CFG", CfgPath); SetProperty(Ctx, "COMPFOUND_SERVER_MAIN_CFG", CfgPath);
@ -205,6 +219,7 @@ namespace WebsitePanel.WIXInstaller
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId)) if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
{ {
AppConfig.LoadComponentSettings(CtxVars); AppConfig.LoadComponentSettings(CtxVars);
VersionGuard(Ctx, CtxVars);
SetProperty(Ctx, "COMPFOUND_ESERVER_ID", CtxVars.ComponentId); SetProperty(Ctx, "COMPFOUND_ESERVER_ID", CtxVars.ComponentId);
SetProperty(Ctx, "COMPFOUND_ESERVER_MAIN_CFG", CfgPath); SetProperty(Ctx, "COMPFOUND_ESERVER_MAIN_CFG", CfgPath);
@ -240,6 +255,7 @@ namespace WebsitePanel.WIXInstaller
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId)) if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
{ {
AppConfig.LoadComponentSettings(CtxVars); AppConfig.LoadComponentSettings(CtxVars);
VersionGuard(Ctx, CtxVars);
SetProperty(Ctx, "COMPFOUND_PORTAL_ID", CtxVars.ComponentId); SetProperty(Ctx, "COMPFOUND_PORTAL_ID", CtxVars.ComponentId);
SetProperty(Ctx, "COMPFOUND_PORTAL_MAIN_CFG", CfgPath); SetProperty(Ctx, "COMPFOUND_PORTAL_MAIN_CFG", CfgPath);
@ -262,6 +278,15 @@ namespace WebsitePanel.WIXInstaller
Ctx["COMPFOUND_PORTAL"] = (HaveAccount && HavePool) ? YesNo.Yes : YesNo.No; Ctx["COMPFOUND_PORTAL"] = (HaveAccount && HavePool) ? YesNo.Yes : YesNo.No;
} }
} }
catch (InvalidOperationException ioex)
{
Log.WriteError(ioex.ToString());
var Text = new Record(1);
Text.SetString(0, ioex.Message);
Ctx.Message(InstallMessage.Error, Text);
return ActionResult.Failure;
}
}
TryApllyNewPassword(Ctx, "PI_SERVER_PASSWORD"); TryApllyNewPassword(Ctx, "PI_SERVER_PASSWORD");
TryApllyNewPassword(Ctx, "PI_ESERVER_PASSWORD"); TryApllyNewPassword(Ctx, "PI_ESERVER_PASSWORD");
TryApllyNewPassword(Ctx, "PI_PORTAL_PASSWORD"); TryApllyNewPassword(Ctx, "PI_PORTAL_PASSWORD");
@ -273,12 +298,16 @@ namespace WebsitePanel.WIXInstaller
[CustomAction] [CustomAction]
public static ActionResult InstallWebFeatures(Session session) public static ActionResult InstallWebFeatures(Session session)
{ {
PopUpDebugger();
var Msg = string.Empty; var Msg = string.Empty;
var Ctx = session; var Ctx = session;
Ctx.AttachToSetupLog(); Ctx.AttachToSetupLog();
var Result = ActionResult.Success; var Result = ActionResult.Success;
var Cancel = new CancellationTokenSource();
try try
{ {
var Animation = AnimateText(Ctx, Cancel, "Configuring");
Log.WriteStart("InstallWebFeatures"); Log.WriteStart("InstallWebFeatures");
if (Tool.GetIsWebRoleInstalled()) if (Tool.GetIsWebRoleInstalled())
{ {
@ -304,6 +333,11 @@ namespace WebsitePanel.WIXInstaller
Log.WriteError(string.Format("InstallWebFeatures: fail - {0}.", ex.ToString())); Log.WriteError(string.Format("InstallWebFeatures: fail - {0}.", ex.ToString()));
Result = ActionResult.Failure; Result = ActionResult.Failure;
} }
finally
{
Cancel.Cancel();
Cancel.Dispose();
}
if (!string.IsNullOrWhiteSpace(Msg)) if (!string.IsNullOrWhiteSpace(Msg))
Log.WriteInfo(string.Format("InstallWebFeatures Tool Log: {0}.", Msg)); Log.WriteInfo(string.Format("InstallWebFeatures Tool Log: {0}.", Msg));
Log.WriteEnd("InstallWebFeatures"); Log.WriteEnd("InstallWebFeatures");
@ -839,9 +873,39 @@ namespace WebsitePanel.WIXInstaller
SetupScript Result = new ExpressScript(CtxVars); SetupScript Result = new ExpressScript(CtxVars);
Result.Actions.Add(new InstallAction(ActionTypes.StopApplicationPool) { SetupVariables = CtxVars }); Result.Actions.Add(new InstallAction(ActionTypes.StopApplicationPool) { SetupVariables = CtxVars });
Result.Actions.Add(new InstallAction(ActionTypes.Backup) { SetupVariables = CtxVars }); Result.Actions.Add(new InstallAction(ActionTypes.Backup) { SetupVariables = CtxVars });
var ServiceCtx = new SetupVariables() { ComponentId = CtxVars.ComponentId };
AppConfig.LoadComponentSettings(ServiceCtx);
if (!string.IsNullOrWhiteSpace(ServiceCtx.ServiceName))
{
CtxVars.ServiceName = ServiceCtx.ServiceName;
CtxVars.ServiceFile = ServiceCtx.ServiceFile;
Result.Actions.Add(new InstallAction(ActionTypes.StopWindowsService));
}
Result.Actions.Add(new InstallAction(ActionTypes.DeleteDirectory) { SetupVariables = CtxVars, Path = CtxVars.InstallFolder }); Result.Actions.Add(new InstallAction(ActionTypes.DeleteDirectory) { SetupVariables = CtxVars, Path = CtxVars.InstallFolder });
return Result; return Result;
} }
private static Task AnimateText(Session Ctx, CancellationTokenSource Cancel, string Message, int Delay = 1000, byte DotCount = 3)
{
return Task.Factory.StartNew(() =>
{
Cancel.Token.ThrowIfCancellationRequested();
byte Current = 0;
while (true)
{
var Text = string.Format("{0} {1}", Message, ".".Repeat(Current++));
using (var Tmp = new Record(1))
{
Tmp.SetString(0, Text);
Ctx.Message(InstallMessage.ActionData, Tmp);
}
if (Current > DotCount)
Current = 0;
Thread.Sleep(Delay);
if (Cancel.Token.IsCancellationRequested)
Cancel.Token.ThrowIfCancellationRequested();
}
}, Cancel.Token);
}
} }
public static class SessionExtension public static class SessionExtension
{ {
@ -852,6 +916,16 @@ namespace WebsitePanel.WIXInstaller
WiXSetup.InstallLogListener(new WiXLogFileListener()); WiXSetup.InstallLogListener(new WiXLogFileListener());
} }
} }
public static class StringExtension
{
public static string Repeat(this string Src, ulong Count)
{
var Result = new StringBuilder();
for (ulong i = 0; i < Count; i++)
Result.Append(Src);
return Result.ToString();
}
}
internal enum WiXInstallType: byte internal enum WiXInstallType: byte
{ {
InstallServer, InstallServer,

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup> <PropertyGroup>
<Version>2.1.0</Version> <Version>2.1.0</Version>
<FileVersion>$(BUILD_NUMBER)</FileVersion> <FileVersion>$(BUILD_NUMBER)</FileVersion>
@ -617,7 +617,6 @@
<!-- Compile and deploy Setup.dll --> <!-- Compile and deploy Setup.dll -->
<Target Name="CreateSetupDLL" DependsOnTargets="ScriptEnterpriseServerDatabase"> <Target Name="CreateSetupDLL" DependsOnTargets="ScriptEnterpriseServerDatabase">
<!-- Compile Setup.dll --> <!-- Compile Setup.dll -->
<MSBuild Projects="$(SetupTrunkFolder)\Sources\WebsitePanel.Installer.sln" Properties="Configuration=$(BuildConfiguration)" /> <MSBuild Projects="$(SetupTrunkFolder)\Sources\WebsitePanel.Installer.sln" Properties="Configuration=$(BuildConfiguration)" />
@ -650,7 +649,36 @@
<Copy SourceFiles="$(SetupBuildFolder)\setup.pdb" DestinationFolder="$(StandaloneInstall)\Setup" Condition="'$(BuildConfiguration)' == 'Debug'" /> <Copy SourceFiles="$(SetupBuildFolder)\setup.pdb" DestinationFolder="$(StandaloneInstall)\Setup" Condition="'$(BuildConfiguration)' == 'Debug'" />
</Target> </Target>
<UsingTask TaskName="RegExpReplace" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Path ParameterType="System.String" Required="true" />
<Pattern ParameterType="System.String" Required="true" />
<Replacement ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.Text.RegularExpressions"/>
<Code Type="Fragment" Language="cs">
<![CDATA[
var Text = File.ReadAllText(Path);
var RegExp = new Regex(Pattern);
Text = RegExp.Replace(Text, Replacement);
File.WriteAllText(Path, Text);
]]>
</Code>
</Task>
</UsingTask>
<Target Name='Demo' >
<TokenReplace Path="C:\Project\Target.config" Token="$MyToken$" Replacement="MyValue"/>
</Target>
<Target Name="CreateStandaloneFullMsi" DependsOnTargets="CreateSetupDLL"> <Target Name="CreateStandaloneFullMsi" DependsOnTargets="CreateSetupDLL">
<Copy SourceFiles="$(TrunkFolder)\Database\install_db.sql" DestinationFiles="$(DatabaseFolder)\wix_install_db.sql" />
<Copy SourceFiles="$(UpdateFolder)\update_db.sql" DestinationFiles="$(DatabaseFolder)\wix_update_db.sql" />
<RegExpReplace Path="$(DatabaseFolder)\wix_install_db.sql" Pattern="USE \[\${install\.database}\]" Replacement="-- WiX" />
<RegExpReplace Path="$(DatabaseFolder)\wix_update_db.sql" Pattern="USE \[\${install\.database}\]" Replacement="-- WiX" />
<MSBuild Projects='$(RootFolder)\WebsitePanel.Installer\Sources\WebsitePanel.WIXInstaller\WebsitePanel.WIXInstaller.csproj' Properties='Configuration=$(BuildConfiguration)' Targets='Build' />
<MSBuild Projects='$(RootFolder)\WebsitePanel.Installer\Sources\Setup.WIXInstaller\Setup.WIXInstaller.wixproj' Properties='Configuration=$(BuildConfiguration)' Targets='Build'> <MSBuild Projects='$(RootFolder)\WebsitePanel.Installer\Sources\Setup.WIXInstaller\Setup.WIXInstaller.wixproj' Properties='Configuration=$(BuildConfiguration)' Targets='Build'>
<Output TaskParameter="TargetOutputs" ItemName="StandaloneFullMsi" /> <Output TaskParameter="TargetOutputs" ItemName="StandaloneFullMsi" />
</MSBuild> </MSBuild>