提交 b955cbd1 编写于 作者: E Enrico Giordani

[Setup] Added the max memory dialog.

[Setup] Added a checkbox to choose whether to add the install dir to PATH.
上级 c5df73b7
......@@ -20,11 +20,40 @@ namespace RedisMsi.CustomActions
[CustomAction]
public static ActionResult UpdateRedisConfig(Session session)
{
// Update port
string port = session.CustomActionData["PORT"];
string configFilePath = session.CustomActionData["CONFIG_PATH"];
if (File.Exists(configFilePath))
{
string originalContent = File.ReadAllText(configFilePath);
string port = session.CustomActionData["PORT"];
string updatedContent = originalContent.Replace("port 6379", "port " + port);
UpdatePortSetting(port, configFilePath);
string useMaxMemoryLimit = session.CustomActionData["USE_MEMORY_LIMITS"];
if (useMaxMemoryLimit == "1")
{
string strMaxMemoryMB = session.CustomActionData["MAXMEMORY"];
try
{
int intMaxMemory = Int32.Parse(strMaxMemoryMB);
if (intMaxMemory <= 0)
{
strMaxMemoryMB = "100";
}
}
catch
{
strMaxMemoryMB = "100";
}
updatedContent = updatedContent.Replace("# maxmemory <bytes>", "maxmemory " + strMaxMemoryMB + "mb");
}
File.WriteAllText(configFilePath, updatedContent);
}
else
{
throw new ApplicationException("UpdateRedisConfig: Config file not found. Could not update its settings.");
}
return ActionResult.Success;
}
......@@ -50,24 +79,5 @@ namespace RedisMsi.CustomActions
return ActionResult.Success;
}
/// <summary>
/// Updates the port in the config file.
/// </summary>
/// <param name="portToUse">The port to have Redis listen at</param>
/// <param name="configFilePath">The path to the Redis config file</param>
private static void UpdatePortSetting(string portToUse, string configFilePath)
{
if (File.Exists(configFilePath))
{
string originalContent = File.ReadAllText(configFilePath);
string updatedContent = originalContent.Replace("port 6379", "port " + portToUse);
File.WriteAllText(configFilePath, updatedContent);
}
else
{
throw new ApplicationException("UpdateRedisConfig: Config file not found. Could not update its settings.");
}
}
}
}
......@@ -7,7 +7,7 @@
Custom actions that update the redis config file during installation
-->
<CustomAction Id="ca_UpdateRedisConfig" BinaryKey="RedisCADLL" DllEntry="UpdateRedisConfig" Execute="deferred" Return="check" Impersonate="no" />
<SetProperty Id="ca_UpdateRedisConfig" Value="CONFIG_PATH=[#file_redis_serviceCONF];PORT=[PORT];" Sequence="execute" Before="ca_UpdateRedisConfig" />
<SetProperty Id="ca_UpdateRedisConfig" Value="CONFIG_PATH=[#file_redis_serviceCONF];PORT=[PORT];MAXMEMORY=[MAXMEMORY];USE_MEMORY_LIMITS=[USE_MEMORY_LIMITS];" Sequence="execute" Before="ca_UpdateRedisConfig" />
<InstallExecuteSequence>
<Custom Action="ca_UpdateRedisConfig" After="InstallFiles"><![CDATA[NOT Installed]]></Custom>
</InstallExecuteSequence>
......
......@@ -37,7 +37,8 @@ First-time install dialog sequence:
- WixUI_WelcomeDlg
- WixUI_LicenseAgreementDlg
- WixUI_InstallDirDlg
- FirwallDlg
- FirewallDlg
- MaxMemoryDlg
- WixUI_VerifyReadyDlg
- WixUI_DiskCostDlg
......@@ -83,21 +84,24 @@ Patch dialog sequence:
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">LicenseAccepted = "1"</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="CustomInstallDirDlg">LicenseAccepted = "1"</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
<Publish Dialog="CustomInstallDirDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
<Publish Dialog="CustomInstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="CustomInstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="FirewallDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="FirewallDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg" Order="1">1</Publish>
<Publish Dialog="FirewallDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="1">1</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="FirewallDlg" Order="1">NOT Installed</Publish>
<Publish Dialog="CustomInstallDirDlg" Control="Next" Event="NewDialog" Value="FirewallDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="CustomInstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="CustomInstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
<Publish Dialog="CustomInstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="FirewallDlg" Control="Back" Event="NewDialog" Value="CustomInstallDirDlg" Order="1">1</Publish>
<Publish Dialog="FirewallDlg" Control="Next" Event="NewDialog" Value="MaxMemoryDlg" Order="1">1</Publish>
<Publish Dialog="MaxMemoryDlg" Control="Back" Event="NewDialog" Value="FirewallDlg" Order="1">1</Publish>
<Publish Dialog="MaxMemoryDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="1">1</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaxMemoryDlg" Order="1">NOT Installed</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
<copyright file="InstallDirDlg.wxs" company="Outercurve Foundation">
Copyright (c) 2004, Outercurve Foundation.
This software is released under Microsoft Reciprocal License (MS-RL).
The license and further copyright text can be found in the file
LICENSE.TXT at the root directory of the distribution.
</copyright>
-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<Dialog Id="CustomInstallDirDlg" Width="370" Height="270" Title="!(loc.InstallDirDlg_Title)">
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.InstallDirDlgDescription)" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.InstallDirDlgTitle)" />
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="FolderLabel" Type="Text" X="20" Y="60" Width="290" Height="30" NoPrefix="yes" Text="!(loc.InstallDirDlgFolderLabel)" />
<Control Id="Folder" Type="PathEdit" X="20" Y="100" Width="320" Height="18" Property="WIXUI_INSTALLDIR" Indirect="yes" />
<Control Id="ChangeFolder" Type="PushButton" X="20" Y="120" Width="56" Height="17" Text="!(loc.InstallDirDlgChange)" />
<Control Id="AddToPathCheckBox" Type="CheckBox" X="20" Y="160" Width="290" Height="17" Property="ADD_INSTALLFOLDER_TO_PATH" CheckBoxValue="1" Text="Add the Redis installation folder to the PATH environment variable." />
</Dialog>
</UI>
</Fragment>
</Wix>
\ No newline at end of file
......@@ -12,18 +12,18 @@
</Control>
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Select whether to add an exception to the Windows Firewall for Redis." />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Firewall Exception" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Port Number and Firewall Exception" />
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="PortLabel" Type="Text" X="20" Y="60" Width="290" Height="30" NoPrefix="yes" Text="Port to run Redis on:" />
<Control Id="PortEdit" Type="Edit" Property="PORT" Height="17" Width="50" X="20" Y="100" />
<Control Id="PortLabel" Type="Text" X="20" Y="60" Width="290" Height="20" NoPrefix="yes" Text="Port to run Redis on:" />
<Control Id="PortEdit" Type="Edit" Property="PORT" Height="17" Width="40" X="20" Y="100" />
<Control Id="FirewallCheckbox" Type="CheckBox" Property="ADD_FIREWALL_RULE" CheckBoxValue="1" Integer="yes" Text="Add an exception to the Windows Firewall" Height="10" Width="200" X="20" Y="140">
<Control Id="FirewallCheckbox" Type="CheckBox" X="20" Y="160" Height="17" Width="200" Property="ADD_FIREWALL_RULE" CheckBoxValue="1" Integer="yes" Text="Add an exception to the Windows Firewall.">
<Condition Action="disable"><![CDATA[FIREWALL_SERVICE_STOPPED = 1]]></Condition>
</Control>
<Control Id="FirewallServiceOffText" Type="Text" Text="{\Warning}The firewall service must be running to add a new exception." Height="34" Width="280" X="20" Y="160" Hidden="yes" NoWrap="no">
<Control Id="FirewallServiceOffText" Type="Text" Text="{\Warning}The firewall service must be running to add a new exception." Height="17" Width="280" X="20" Y="140" Hidden="yes" NoWrap="no">
<Condition Action="show"><![CDATA[FIREWALL_SERVICE_STOPPED = 1]]></Condition>
</Control>
</Dialog>
......
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<Dialog Id="MaxMemoryDlg" Width="370" Height="270" Title="[ProductName] Setup">
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Select whether to use a memory limit or not." />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Memory Limit" />
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="MaxMemoryCheckbox" Type="CheckBox" Property="USE_MEMORY_LIMITS" CheckBoxValue="1" Integer="yes" Text="Set the Max Memory limit" Height="10" Width="300" X="20" Y="60" />
<Control Id="MaxMemoryLabel1" Type="Text" X="20" Y="102" Width="50" Height="17" NoPrefix="yes" Text="Max Memory:">
<Condition Action="enable" >USE_MEMORY_LIMITS = 1</Condition>
<Condition Action="disable"><![CDATA[USE_MEMORY_LIMITS <>1]]></Condition>
</Control>
<Control Id="MaxMemoryEdit" Type="Edit" X="75" Y="100" Width="40" Height="17" Property="MAXMEMORY" >
<Condition Action="enable" >USE_MEMORY_LIMITS = 1</Condition>
<Condition Action="disable"><![CDATA[USE_MEMORY_LIMITS <>1]]></Condition>
</Control>
<Control Id="MaxMemoryLabel2" Type="Text" X="120" Y="102" Width="20" Height="17" NoPrefix="yes" Text="MB">
<Condition Action="enable" >USE_MEMORY_LIMITS = 1</Condition>
<Condition Action="disable"><![CDATA[USE_MEMORY_LIMITS <>1]]></Condition>
</Control>
</Dialog>
</UI>
</Fragment>
</Wix>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:fw="http://schemas.microsoft.com/wix/FirewallExtension">
<!--
<!--
64-bit installer
Example installation (command-line):
......@@ -18,55 +18,75 @@
-->
<Product Id="*"
Name="Redis on Windows"
Language="1033"
Version="3.0.300"
Manufacturer="MSOpenTech"
UpgradeCode="{05410198-7212-4FC4-B7C8-AFEFC3DA0FBC}">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine" />
<Product Id="*"
Name="Redis on Windows"
Language="1033"
Version="3.0.300"
Manufacturer="MSOpenTech"
UpgradeCode="{05410198-7212-4FC4-B7C8-AFEFC3DA0FBC}">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<!--User interface hook-->
<UIRef Id="CustomInstallDir"/>
<!--Properties-->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<Property Id="ARPURLINFOABOUT" Value="https://github.com/MSOpenTech/redis" />
<Property Id="PORT" Value="6379" />
<Property Id="ADD_FIREWALL_RULE" Value="1" />
<Property Id="FIREWALL_SERVICE_STOPPED" Value="0" />
<!--Link-time variables-->
<WixVariable Id="WixUILicenseRtf" Value="License.rtf"/>
<WixVariable Id="WixUIDialogBmp" Value="Images/redis_background.jpg"/>
<WixVariable Id="WixUIBannerBmp" Value="Images/top_banner.jpg"/>
<WixVariable Id="DocumentationFolder" Value="..\..\setups\documentation"/>
<!--Link in custom actions, referencing one will pull in all-->
<CustomActionRef Id="ca_UpdateRedisConfig"/>
<!--User interface hook-->
<UIRef Id="CustomInstallDir"/>
<!--Properties-->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<Property Id="ARPURLINFOABOUT" Value="https://github.com/MSOpenTech/redis" />
<Property Id="PORT" Value="6379" />
<Property Id="ADD_FIREWALL_RULE" Value="1" />
<Property Id="FIREWALL_SERVICE_STOPPED" Value="0" />
<Property Id="MAXMEMORY" Value="100" />
<Property Id="USE_MEMORY_LIMITS" Secure="yes"/>
<Property Id="ADD_INSTALLFOLDER_TO_PATH" Secure="yes"/>
<!--Link-time variables-->
<WixVariable Id="WixUILicenseRtf" Value="License.rtf"/>
<WixVariable Id="WixUIDialogBmp" Value="Images/redis_background.jpg"/>
<WixVariable Id="WixUIBannerBmp" Value="Images/top_banner.jpg"/>
<WixVariable Id="DocumentationFolder" Value="..\..\setups\documentation"/>
<!--Link in custom actions, referencing one will pull in all-->
<CustomActionRef Id="ca_UpdateRedisConfig"/>
<!--Features-->
<Feature Id="ProductFeature" Title="Redis" Level="1">
<ComponentGroupRef Id="FileComponents" />
<ComponentGroupRef Id="SymbolsComponents" />
<ComponentGroupRef Id="WindowsServiceComponents" />
<ComponentGroupRef Id="DocumentationComponents" />
<ComponentGroupRef Id="SetPathComponents" />
</Feature>
</Product>
<!--Features-->
<Feature Id="ProductFeature" Title="Redis" Level="1">
<ComponentGroupRef Id="FileComponents" />
<ComponentGroupRef Id="SymbolsComponents" />
<ComponentGroupRef Id="WindowsServiceComponents" />
<ComponentGroupRef Id="DocumentationComponents" />
</Feature>
</Product>
<Fragment>
<ComponentGroup Id="SetPathComponents" Directory="INSTALLFOLDER">
<Component Id="SetEnvironmentVariables" Guid="{33F930D5-EE5D-4D2C-9DC9-6AE1E176BDCD}" KeyPath="yes">
<Condition>ADD_INSTALLFOLDER_TO_PATH</Condition>
<Environment Action="set"
Id="SetPath"
Name="PATH"
System="yes"
Value="[INSTALLFOLDER]"
Permanent="no"
Part="last"
/>
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<!--Directory structure to create-->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="Redis">
<Directory Id="LogsFolder" Name="Logs" />
<Fragment>
<!--Directory structure to create-->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="Redis">
<Directory Id="LogsFolder" Name="Logs" />
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
</Fragment>
</Wix>
\ No newline at end of file
......@@ -44,6 +44,8 @@
<Compile Include="CustomActions.wxs" />
<Compile Include="Dialogs\CustomInstallDir.wxs" />
<Compile Include="Dialogs\FirewallDialog.wxs" />
<Compile Include="Dialogs\MaxMemoryDialog.wxs" />
<Compile Include="Dialogs\CustomInstallDirDlg.wxs" />
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册