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 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 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>

View file

@ -477,8 +477,8 @@
<Binary Id="bannrbmp" SourceFile="bannrbmp.bmp" />
<Binary Id="passmark" SourceFile="passmark.ico" />
<Binary Id="failmark" SourceFile="failmark.ico" />
<Binary Id="InstallDB" SourceFile="$(var.PROJECTPATH)\Database\wix_install_db.sql" />
<Binary Id="UpdateDB" SourceFile="$(var.PROJECTPATH)\Database\wix_update_db.sql" />
<Binary Id="InstallDB" SourceFile="$(var.PROJECTPATH)\Deploy\$(var.BUILD)\Database\wix_install_db.sql" />
<Binary Id="UpdateDB" SourceFile="$(var.PROJECTPATH)\Deploy\$(var.BUILD)\Database\wix_update_db.sql" />
<WixVariable Id="WixUIBannerBmp" Value="bannrbmp.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="dlgbmp.bmp" />
<WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
@ -643,13 +643,13 @@
<InstallExecuteSequence>
<!--Preinstall.-->
<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".-->
<Custom Action="CA_PropertyOnServerPrepare" Before="InstallFiles"><![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]]></Custom>
<Custom Action="CA_PropertyOnEServerPrepare" Before="InstallFiles"><![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]]></Custom>
<Custom Action="CA_PropertyOnPortalPrepare" Before="InstallFiles"><![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]]></Custom>
<!--Preparation when "old to new installer update". Also disabled in Maintenance mode.-->
<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 AND NOT(&ServerFeature=-1 AND !ServerFeature=3)]]></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 AND NOT (&EnterpriseServerFeature=-1 AND !EnterpriseServerFeature=3)]]></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 AND NOT (&PortalFeature=-1 AND !PortalFeature=3)]]></Custom>
<!--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_OnServerInstall" After="InstallFiles"><![CDATA[(&ServerFeature=3) AND NOT(!ServerFeature=3)]]></Custom>
@ -713,12 +713,7 @@
Server="[DB_SERVER]"
Database="[DB_DATABASE]"
User="SqlUpdateUser">
<sql:SqlString Id="SqlVersionUpdateSql" SQL="IF NOT EXISTS (SELECT * FROM dbo.Versions WHERE DatabaseVersion = '$(var.sql_release_version)')
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"
<sql:SqlScript Id="SqlUpdateScriptSql" BinaryKey="UpdateDB" Sequence="2"
ContinueOnError="no" ExecuteOnInstall="yes" ExecuteOnReinstall="yes" ExecuteOnUninstall="no"/>
</sql:SqlDatabase>
</Component>
@ -739,12 +734,7 @@
DropOnInstall="no" DropOnReinstall="no" DropOnUninstall="no"
Server="[DB_SERVER]"
Database="[DB_DATABASE]">
<sql:SqlString Id="SqlVersionUpdateWin" SQL="IF NOT EXISTS (SELECT * FROM dbo.Versions WHERE DatabaseVersion = '$(var.sql_release_version)')
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"
<sql:SqlScript Id="SqlUpdateScriptWin" BinaryKey="UpdateDB" Sequence="11"
ContinueOnError="no" ExecuteOnInstall="yes" ExecuteOnReinstall="yes" ExecuteOnUninstall="no" />
</sql:SqlDatabase>
</Component>
@ -758,7 +748,9 @@
<Component Id="comp_WebsitePanel_reg_locator" Directory="WSP_INSTALL_DIR" Guid="{CC35E1B5-3E29-4AD1-991C-2904E4DCB099}">
<RegistryValue Root='HKLM' Key='SOFTWARE\[ProductName]'
Name='Base' Value='[WSP_INSTALL_DIR]'
Type='string' />
Type='string' />
<RemoveFolder Id='CleanUpWSP' On='uninstall'/>
</Component>
</ComponentGroup>
</Fragment>

View file

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

View file

@ -134,22 +134,18 @@ Global
{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

View file

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

View file

@ -135,6 +135,7 @@ namespace WebsitePanel.Setup.Internal
//Dst.IISVersion = Utils.GetVersionSetupParameter(Hash, "IISVersion");
Dst.SetupXml = Utils.GetStringSetupParameter(Hash, "SetupXml");
Dst.ServerPassword = Utils.GetStringSetupParameter(Hash, Global.Parameters.ServerPassword);
Dst.UpdateServerPassword = true;
Dst.WebSiteIP = Utils.GetStringSetupParameter(Hash, Global.Parameters.WebSiteIP);
Dst.WebSitePort = Utils.GetStringSetupParameter(Hash, Global.Parameters.WebSitePort);
@ -2191,38 +2192,41 @@ namespace WebsitePanel.Setup.Internal
Log.WriteEnd(Msg);
InstallLog.AppendLine(Msg);
}
try
else
{
string domain = Context.UserDomain;
if (string.IsNullOrEmpty(domain))
domain = ".";
try
{
string domain = Context.UserDomain;
if (string.IsNullOrEmpty(domain))
domain = ".";
string arguments = string.Empty;
if (Context.UseUserCredentials)
arguments = string.Format("/i /LogFile=\"\" /user={0}\\{1} /password={2}", domain, Context.UserAccount, Context.UserPassword);
else
arguments = "/i /LogFile= ''";
string arguments = string.Empty;
if (Context.UseUserCredentials)
arguments = string.Format("/i /LogFile=\"\" /user={0}\\{1} /password={2}", domain, Context.UserAccount, Context.UserPassword);
else
arguments = "/i /LogFile= ''";
ManagedInstallerClass.InstallHelper(new[] { arguments, path });
//add rollback action
RollBack.RegisterWindowsService(path, service);
var Msg = string.Format("Registered \"{0}\" Windows service ", service);
//update log
Log.WriteEnd(Msg);
//update install log
InstallLog.AppendLine(Msg);
ManagedInstallerClass.InstallHelper(new[] { arguments, path });
//add rollback action
RollBack.RegisterWindowsService(path, service);
var Msg = string.Format("Registered \"{0}\" Windows service ", service);
//update log
Log.WriteEnd(Msg);
//update install log
InstallLog.AppendLine(Msg);
// update config setings
AppConfig.EnsureComponentConfig(componentId);
AppConfig.SetComponentSettingStringValue(componentId, "ServiceName", service);
AppConfig.SetComponentSettingStringValue(componentId, "ServiceFile", path);
AppConfig.SaveConfiguration();
}
catch (Exception ex)
{
Log.WriteError(string.Format("Unable to register \"{0}\" Windows service.", service), null);
InstallLog.AppendLine(string.Format("- Failed to register \"{0}\" windows service ", service));
}
// update config setings
AppConfig.EnsureComponentConfig(componentId);
AppConfig.SetComponentSettingStringValue(componentId, "ServiceName", service);
AppConfig.SetComponentSettingStringValue(componentId, "ServiceFile", path);
AppConfig.SaveConfiguration();
}
catch (Exception ex)
{
Log.WriteError(string.Format("Unable to register \"{0}\" Windows service.", service), null);
InstallLog.AppendLine(string.Format("- Failed to register \"{0}\" windows service ", service));
}
}
}
catch (Exception ex)
{
@ -3213,7 +3217,7 @@ namespace WebsitePanel.Setup.Internal
return;
string path = Path.Combine(Context.InstallationFolder, Context.ConfigurationFile);
string hash = Context.ServerPassword;
string hash = Utils.ComputeSHA1(Context.ServerPassword);
if (!File.Exists(path))
{
@ -4429,6 +4433,7 @@ namespace WebsitePanel.Setup.Internal
break;
case ModeExtension.Backup:
Script = new BackupScript(Context);
Script.Actions.Add(new InstallAction(ActionTypes.StopWindowsService));
break;
default:
throw new NotImplementedException("Uninstall " + ModeExtension.ToString());

View file

@ -28,7 +28,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Configuration.Install;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
@ -37,10 +36,12 @@ using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.ServiceProcess;
using System.Text.RegularExpressions;
using System.Xml;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Deployment.WindowsInstaller;
using WebsitePanel.Setup;
using WebsitePanel.Setup.Internal;
using WebsitePanel.WIXInstaller.Common;
@ -92,6 +93,7 @@ namespace WebsitePanel.WIXInstaller
[CustomAction]
public static ActionResult MaintenanceServer(Session session)
{
PopUpDebugger();
var Result = ActionResult.Success;
Log.WriteStart("MaintenanceServer");
Result = ProcessInstall(session, WiXInstallType.MaintenanceServer);
@ -101,6 +103,7 @@ namespace WebsitePanel.WIXInstaller
[CustomAction]
public static ActionResult MaintenanceEServer(Session session)
{
PopUpDebugger();
var Result = ActionResult.Success;
Log.WriteStart("MaintenanceEServer");
Result = ProcessInstall(session, WiXInstallType.MaintenanceEnterpriseServer);
@ -110,6 +113,7 @@ namespace WebsitePanel.WIXInstaller
[CustomAction]
public static ActionResult MaintenancePortal(Session session)
{
PopUpDebugger();
var Result = ActionResult.Success;
Log.WriteStart("MaintenancePortal");
Result = ProcessInstall(session, WiXInstallType.MaintenancePortal);
@ -160,6 +164,13 @@ namespace WebsitePanel.WIXInstaller
}
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;
Ctx.AttachToSetupLog();
@ -176,90 +187,104 @@ namespace WebsitePanel.WIXInstaller
var CfgPath = FindMainConfig(DirList);
if (!string.IsNullOrWhiteSpace(CfgPath))
{
var EServerUrl = string.Empty;
AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = CfgPath });
var CtxVars = new SetupVariables();
CtxVars.ComponentId = WiXSetup.GetComponentID(CfgPath, Global.Server.ComponentCode);
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
try
{
AppConfig.LoadComponentSettings(CtxVars);
SetProperty(Ctx, "COMPFOUND_SERVER_ID", CtxVars.ComponentId);
SetProperty(Ctx, "COMPFOUND_SERVER_MAIN_CFG", CfgPath);
SetProperty(Ctx, "PI_SERVER_IP", CtxVars.WebSiteIP);
SetProperty(Ctx, "PI_SERVER_PORT", CtxVars.WebSitePort);
SetProperty(Ctx, "PI_SERVER_HOST", CtxVars.WebSiteDomain);
SetProperty(Ctx, "PI_SERVER_LOGIN", CtxVars.UserAccount);
SetProperty(Ctx, "PI_SERVER_DOMAIN", CtxVars.UserDomain);
SetProperty(Ctx, "PI_SERVER_INSTALL_DIR", CtxVars.InstallFolder);
SetProperty(Ctx, "WSP_INSTALL_DIR", Directory.GetParent(CtxVars.InstallFolder).FullName);
var HaveAccount = SecurityUtils.UserExists(CtxVars.UserDomain, CtxVars.UserAccount);
bool HavePool = Tool.AppPoolExists(CtxVars.ApplicationPool);
Ctx["COMPFOUND_SERVER"] = (HaveAccount && HavePool) ? YesNo.Yes : YesNo.No;
}
CtxVars.ComponentId = WiXSetup.GetComponentID(CfgPath, Global.EntServer.ComponentCode);
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
{
AppConfig.LoadComponentSettings(CtxVars);
SetProperty(Ctx, "COMPFOUND_ESERVER_ID", CtxVars.ComponentId);
SetProperty(Ctx, "COMPFOUND_ESERVER_MAIN_CFG", CfgPath);
SetProperty(Ctx, "PI_ESERVER_IP", CtxVars.WebSiteIP);
SetProperty(Ctx, "PI_ESERVER_PORT", CtxVars.WebSitePort);
SetProperty(Ctx, "PI_ESERVER_HOST", CtxVars.WebSiteDomain);
SetProperty(Ctx, "PI_ESERVER_LOGIN", CtxVars.UserAccount);
SetProperty(Ctx, "PI_ESERVER_DOMAIN", CtxVars.UserDomain);
EServerUrl = string.Format("http://{0}:{1}", CtxVars.WebSiteIP, CtxVars.WebSitePort);
SetProperty(Ctx, "PI_ESERVER_INSTALL_DIR", CtxVars.InstallFolder);
SetProperty(Ctx, "WSP_INSTALL_DIR", Directory.GetParent(CtxVars.InstallFolder).FullName);
var ConnStr = new SqlConnectionStringBuilder(CtxVars.DbInstallConnectionString);
SetProperty(Ctx, "DB_CONN", ConnStr.ToString());
SetProperty(Ctx, "DB_SERVER", ConnStr.DataSource);
SetProperty(Ctx, "DB_AUTH", ConnStr.IntegratedSecurity ? SQL_AUTH_WINDOWS : SQL_AUTH_SERVER);
if (!ConnStr.IntegratedSecurity)
var EServerUrl = string.Empty;
AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = CfgPath });
var CtxVars = new SetupVariables();
CtxVars.ComponentId = WiXSetup.GetComponentID(CfgPath, Global.Server.ComponentCode);
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
{
SetProperty(Ctx, "DB_LOGIN", ConnStr.UserID);
SetProperty(Ctx, "DB_PASSWORD", ConnStr.Password);
AppConfig.LoadComponentSettings(CtxVars);
VersionGuard(Ctx, CtxVars);
SetProperty(Ctx, "COMPFOUND_SERVER_ID", CtxVars.ComponentId);
SetProperty(Ctx, "COMPFOUND_SERVER_MAIN_CFG", CfgPath);
SetProperty(Ctx, "PI_SERVER_IP", CtxVars.WebSiteIP);
SetProperty(Ctx, "PI_SERVER_PORT", CtxVars.WebSitePort);
SetProperty(Ctx, "PI_SERVER_HOST", CtxVars.WebSiteDomain);
SetProperty(Ctx, "PI_SERVER_LOGIN", CtxVars.UserAccount);
SetProperty(Ctx, "PI_SERVER_DOMAIN", CtxVars.UserDomain);
SetProperty(Ctx, "PI_SERVER_INSTALL_DIR", CtxVars.InstallFolder);
SetProperty(Ctx, "WSP_INSTALL_DIR", Directory.GetParent(CtxVars.InstallFolder).FullName);
var HaveAccount = SecurityUtils.UserExists(CtxVars.UserDomain, CtxVars.UserAccount);
bool HavePool = Tool.AppPoolExists(CtxVars.ApplicationPool);
Ctx["COMPFOUND_SERVER"] = (HaveAccount && HavePool) ? YesNo.Yes : YesNo.No;
}
ConnStr = new SqlConnectionStringBuilder(CtxVars.ConnectionString);
SetProperty(Ctx, "DB_DATABASE", ConnStr.InitialCatalog);
CtxVars.ComponentId = WiXSetup.GetComponentID(CfgPath, Global.EntServer.ComponentCode);
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
{
AppConfig.LoadComponentSettings(CtxVars);
VersionGuard(Ctx, CtxVars);
var HaveAccount = SecurityUtils.UserExists(CtxVars.UserDomain, CtxVars.UserAccount);
bool HavePool = Tool.AppPoolExists(CtxVars.ApplicationPool);
SetProperty(Ctx, "COMPFOUND_ESERVER_ID", CtxVars.ComponentId);
SetProperty(Ctx, "COMPFOUND_ESERVER_MAIN_CFG", CfgPath);
Ctx["COMPFOUND_ESERVER"] = (HaveAccount && HavePool) ? YesNo.Yes : YesNo.No;
SetProperty(Ctx, "PI_ESERVER_IP", CtxVars.WebSiteIP);
SetProperty(Ctx, "PI_ESERVER_PORT", CtxVars.WebSitePort);
SetProperty(Ctx, "PI_ESERVER_HOST", CtxVars.WebSiteDomain);
SetProperty(Ctx, "PI_ESERVER_LOGIN", CtxVars.UserAccount);
SetProperty(Ctx, "PI_ESERVER_DOMAIN", CtxVars.UserDomain);
EServerUrl = string.Format("http://{0}:{1}", CtxVars.WebSiteIP, CtxVars.WebSitePort);
SetProperty(Ctx, "PI_ESERVER_INSTALL_DIR", CtxVars.InstallFolder);
SetProperty(Ctx, "WSP_INSTALL_DIR", Directory.GetParent(CtxVars.InstallFolder).FullName);
var ConnStr = new SqlConnectionStringBuilder(CtxVars.DbInstallConnectionString);
SetProperty(Ctx, "DB_CONN", ConnStr.ToString());
SetProperty(Ctx, "DB_SERVER", ConnStr.DataSource);
SetProperty(Ctx, "DB_AUTH", ConnStr.IntegratedSecurity ? SQL_AUTH_WINDOWS : SQL_AUTH_SERVER);
if (!ConnStr.IntegratedSecurity)
{
SetProperty(Ctx, "DB_LOGIN", ConnStr.UserID);
SetProperty(Ctx, "DB_PASSWORD", ConnStr.Password);
}
ConnStr = new SqlConnectionStringBuilder(CtxVars.ConnectionString);
SetProperty(Ctx, "DB_DATABASE", ConnStr.InitialCatalog);
var HaveAccount = SecurityUtils.UserExists(CtxVars.UserDomain, CtxVars.UserAccount);
bool HavePool = Tool.AppPoolExists(CtxVars.ApplicationPool);
Ctx["COMPFOUND_ESERVER"] = (HaveAccount && HavePool) ? YesNo.Yes : YesNo.No;
}
CtxVars.ComponentId = WiXSetup.GetComponentID(CfgPath, Global.WebPortal.ComponentCode);
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
{
AppConfig.LoadComponentSettings(CtxVars);
VersionGuard(Ctx, CtxVars);
SetProperty(Ctx, "COMPFOUND_PORTAL_ID", CtxVars.ComponentId);
SetProperty(Ctx, "COMPFOUND_PORTAL_MAIN_CFG", CfgPath);
SetProperty(Ctx, "PI_PORTAL_IP", CtxVars.WebSiteIP);
SetProperty(Ctx, "PI_PORTAL_PORT", CtxVars.WebSitePort);
SetProperty(Ctx, "PI_PORTAL_HOST", CtxVars.WebSiteDomain);
SetProperty(Ctx, "PI_PORTAL_LOGIN", CtxVars.UserAccount);
SetProperty(Ctx, "PI_PORTAL_DOMAIN", CtxVars.UserDomain);
if (!SetProperty(Ctx, "PI_ESERVER_URL", CtxVars.EnterpriseServerURL))
if (!SetProperty(Ctx, "PI_ESERVER_URL", EServerUrl))
SetProperty(Ctx, "PI_ESERVER_URL", Global.WebPortal.DefaultEntServURL);
SetProperty(Ctx, "PI_PORTAL_INSTALL_DIR", CtxVars.InstallFolder);
SetProperty(Ctx, "WSP_INSTALL_DIR", Directory.GetParent(CtxVars.InstallFolder).FullName);
var HaveAccount = SecurityUtils.UserExists(CtxVars.UserDomain, CtxVars.UserAccount);
bool HavePool = Tool.AppPoolExists(CtxVars.ApplicationPool);
Ctx["COMPFOUND_PORTAL"] = (HaveAccount && HavePool) ? YesNo.Yes : YesNo.No;
}
}
CtxVars.ComponentId = WiXSetup.GetComponentID(CfgPath, Global.WebPortal.ComponentCode);
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
catch (InvalidOperationException ioex)
{
AppConfig.LoadComponentSettings(CtxVars);
SetProperty(Ctx, "COMPFOUND_PORTAL_ID", CtxVars.ComponentId);
SetProperty(Ctx, "COMPFOUND_PORTAL_MAIN_CFG", CfgPath);
SetProperty(Ctx, "PI_PORTAL_IP", CtxVars.WebSiteIP);
SetProperty(Ctx, "PI_PORTAL_PORT", CtxVars.WebSitePort);
SetProperty(Ctx, "PI_PORTAL_HOST", CtxVars.WebSiteDomain);
SetProperty(Ctx, "PI_PORTAL_LOGIN", CtxVars.UserAccount);
SetProperty(Ctx, "PI_PORTAL_DOMAIN", CtxVars.UserDomain);
if (!SetProperty(Ctx, "PI_ESERVER_URL", CtxVars.EnterpriseServerURL))
if (!SetProperty(Ctx, "PI_ESERVER_URL", EServerUrl))
SetProperty(Ctx, "PI_ESERVER_URL", Global.WebPortal.DefaultEntServURL);
SetProperty(Ctx, "PI_PORTAL_INSTALL_DIR", CtxVars.InstallFolder);
SetProperty(Ctx, "WSP_INSTALL_DIR", Directory.GetParent(CtxVars.InstallFolder).FullName);
var HaveAccount = SecurityUtils.UserExists(CtxVars.UserDomain, CtxVars.UserAccount);
bool HavePool = Tool.AppPoolExists(CtxVars.ApplicationPool);
Ctx["COMPFOUND_PORTAL"] = (HaveAccount && HavePool) ? YesNo.Yes : YesNo.No;
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");
@ -273,12 +298,16 @@ namespace WebsitePanel.WIXInstaller
[CustomAction]
public static ActionResult InstallWebFeatures(Session session)
{
PopUpDebugger();
var Msg = string.Empty;
var Ctx = session;
Ctx.AttachToSetupLog();
var Result = ActionResult.Success;
var Cancel = new CancellationTokenSource();
try
{
{
var Animation = AnimateText(Ctx, Cancel, "Configuring");
Log.WriteStart("InstallWebFeatures");
if (Tool.GetIsWebRoleInstalled())
{
@ -304,11 +333,16 @@ namespace WebsitePanel.WIXInstaller
Log.WriteError(string.Format("InstallWebFeatures: fail - {0}.", ex.ToString()));
Result = ActionResult.Failure;
}
finally
{
Cancel.Cancel();
Cancel.Dispose();
}
if (!string.IsNullOrWhiteSpace(Msg))
Log.WriteInfo(string.Format("InstallWebFeatures Tool Log: {0}.", Msg));
Log.WriteEnd("InstallWebFeatures");
return Result;
}
}
// Install.
[CustomAction]
public static ActionResult OnServerInstall(Session session)
@ -839,9 +873,39 @@ namespace WebsitePanel.WIXInstaller
SetupScript Result = new ExpressScript(CtxVars);
Result.Actions.Add(new InstallAction(ActionTypes.StopApplicationPool) { 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 });
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
{
@ -852,6 +916,16 @@ namespace WebsitePanel.WIXInstaller
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
{
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>
<Version>2.1.0</Version>
<FileVersion>$(BUILD_NUMBER)</FileVersion>
@ -617,7 +617,6 @@
<!-- Compile and deploy Setup.dll -->
<Target Name="CreateSetupDLL" DependsOnTargets="ScriptEnterpriseServerDatabase">
<!-- Compile Setup.dll -->
<MSBuild Projects="$(SetupTrunkFolder)\Sources\WebsitePanel.Installer.sln" Properties="Configuration=$(BuildConfiguration)" />
@ -649,8 +648,37 @@
<Copy SourceFiles="$(SetupBuildFolder)\setup.dll" DestinationFolder="$(StandaloneInstall)\Setup" />
<Copy SourceFiles="$(SetupBuildFolder)\setup.pdb" DestinationFolder="$(StandaloneInstall)\Setup" Condition="'$(BuildConfiguration)' == 'Debug'" />
</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">
<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'>
<Output TaskParameter="TargetOutputs" ItemName="StandaloneFullMsi" />
</MSBuild>