From 8e4dcd53607c70ea08a021087a6a395361428dc5 Mon Sep 17 00:00:00 2001 From: NickMRamirez Date: Sat, 28 Feb 2015 13:09:49 -0500 Subject: [PATCH] Added a dialog to the installer that lets the user customize the port and firewall exception. The port will update the config file via a new WiX Custom action project. --- msvs/RedisServer.sln | 22 ++++- msvs/RedisWindowsX64/FileComponents.wxs | 65 ------------- msvs/RedisWindowsX64/Product.wxs | 39 -------- .../CustomAction.config | 32 ++++++ .../CustomAction.cs | 50 ++++++++++ .../Properties/AssemblyInfo.cs | 34 +++++++ .../RedisWindowsX64.CustomActions.csproj | 66 +++++++++++++ .../Components/DocumentationComponents.wxs | 21 ++++ .../Components/FileComponents.wxs | 25 +++++ .../Components/WindowsServiceComponents.wxs | 59 ++++++++++++ .../Dialogs/CustomInstallDir.wxs | 91 ++++++++++++++++++ .../Dialogs/FirewallDialog.wxs | 25 +++++ .../Images}/redis_background.jpg | Bin .../RedisWindowsX64/Images}/top_banner.jpg | Bin msvs/{ => msi}/RedisWindowsX64/License.rtf | Bin msvs/msi/RedisWindowsX64/Product.wxs | 73 ++++++++++++++ .../RedisWindowsX64/RedisWindowsX64.wixproj | 44 +++++++-- 17 files changed, 531 insertions(+), 115 deletions(-) delete mode 100644 msvs/RedisWindowsX64/FileComponents.wxs delete mode 100644 msvs/RedisWindowsX64/Product.wxs create mode 100644 msvs/msi/RedisWindowsX64.CustomActions/CustomAction.config create mode 100644 msvs/msi/RedisWindowsX64.CustomActions/CustomAction.cs create mode 100644 msvs/msi/RedisWindowsX64.CustomActions/Properties/AssemblyInfo.cs create mode 100644 msvs/msi/RedisWindowsX64.CustomActions/RedisWindowsX64.CustomActions.csproj create mode 100644 msvs/msi/RedisWindowsX64/Components/DocumentationComponents.wxs create mode 100644 msvs/msi/RedisWindowsX64/Components/FileComponents.wxs create mode 100644 msvs/msi/RedisWindowsX64/Components/WindowsServiceComponents.wxs create mode 100644 msvs/msi/RedisWindowsX64/Dialogs/CustomInstallDir.wxs create mode 100644 msvs/msi/RedisWindowsX64/Dialogs/FirewallDialog.wxs rename msvs/{RedisWindowsX64 => msi/RedisWindowsX64/Images}/redis_background.jpg (100%) rename msvs/{RedisWindowsX64 => msi/RedisWindowsX64/Images}/top_banner.jpg (100%) rename msvs/{ => msi}/RedisWindowsX64/License.rtf (100%) create mode 100644 msvs/msi/RedisWindowsX64/Product.wxs rename msvs/{ => msi}/RedisWindowsX64/RedisWindowsX64.wixproj (67%) diff --git a/msvs/RedisServer.sln b/msvs/RedisServer.sln index 04813a13..1df740c1 100644 --- a/msvs/RedisServer.sln +++ b/msvs/RedisServer.sln @@ -42,7 +42,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReleasePackagingTool", "Rel {A65C2CD6-72A3-441A-AEA3-D754BEA9A86A} = {A65C2CD6-72A3-441A-AEA3-D754BEA9A86A} EndProjectSection EndProject -Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "RedisWindowsX64", "RedisWindowsX64\RedisWindowsX64.wixproj", "{C829D256-16B4-4DC7-9BF9-6814F76B441E}" +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "RedisWindowsX64", "msi\RedisWindowsX64\RedisWindowsX64.wixproj", "{C829D256-16B4-4DC7-9BF9-6814F76B441E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RedisWindowsX64.CustomActions", "msi\RedisWindowsX64.CustomActions\RedisWindowsX64.CustomActions.csproj", "{A917027E-D229-46C9-B969-1F4CE7D5D2CA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -199,15 +201,29 @@ Global {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Debug|Win32.ActiveCfg = Debug|x86 {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Debug|Win32.Build.0 = Debug|x86 {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Debug|x64.ActiveCfg = Debug|x86 - {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Debug|x64.Build.0 = Debug|x86 {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Debug|x86.ActiveCfg = Debug|x86 + {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Debug|x86.Build.0 = Debug|x86 {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Release|Mixed Platforms.ActiveCfg = Release|x86 {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Release|Mixed Platforms.Build.0 = Release|x86 {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Release|Win32.ActiveCfg = Release|x86 {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Release|Win32.Build.0 = Release|x86 {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Release|x64.ActiveCfg = Release|x86 - {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Release|x64.Build.0 = Release|x86 {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Release|x86.ActiveCfg = Release|x86 + {C829D256-16B4-4DC7-9BF9-6814F76B441E}.Release|x86.Build.0 = Release|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Debug|Mixed Platforms.Build.0 = Debug|x64 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Debug|Win32.ActiveCfg = Debug|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Debug|Win32.Build.0 = Debug|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Debug|x64.ActiveCfg = Debug|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Debug|x86.ActiveCfg = Debug|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Debug|x86.Build.0 = Debug|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Release|Mixed Platforms.Build.0 = Release|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Release|Win32.ActiveCfg = Release|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Release|Win32.Build.0 = Release|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Release|x64.ActiveCfg = Release|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Release|x86.ActiveCfg = Release|x86 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/msvs/RedisWindowsX64/FileComponents.wxs b/msvs/RedisWindowsX64/FileComponents.wxs deleted file mode 100644 index b1bfff43..00000000 --- a/msvs/RedisWindowsX64/FileComponents.wxs +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/msvs/RedisWindowsX64/Product.wxs b/msvs/RedisWindowsX64/Product.wxs deleted file mode 100644 index 8d60c8c8..00000000 --- a/msvs/RedisWindowsX64/Product.wxs +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/msvs/msi/RedisWindowsX64.CustomActions/CustomAction.config b/msvs/msi/RedisWindowsX64.CustomActions/CustomAction.config new file mode 100644 index 00000000..de951b78 --- /dev/null +++ b/msvs/msi/RedisWindowsX64.CustomActions/CustomAction.config @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/msvs/msi/RedisWindowsX64.CustomActions/CustomAction.cs b/msvs/msi/RedisWindowsX64.CustomActions/CustomAction.cs new file mode 100644 index 00000000..a81febc3 --- /dev/null +++ b/msvs/msi/RedisWindowsX64.CustomActions/CustomAction.cs @@ -0,0 +1,50 @@ +using System; +using System.IO; +using Microsoft.Deployment.WindowsInstaller; + +namespace RedisWindowsX64.CustomActions +{ + /// + /// Defines actions to take during the MSI install that don't + /// come standard with WiX. + /// + public class CustomActions + { + /// + /// Overwrites settings in the Redis config file using values from the installer. + /// + /// The install session context + /// Returns Success when the method completes. Exceptions will bubble up and + /// cause the installer to roll back. + [CustomAction] + public static ActionResult UpdateRedisConfig(Session session) + { + // Update port + string port = session.CustomActionData["PORT"]; + string configFilePath = session.CustomActionData["CONFIG_PATH"]; + + UpdatePortSetting(port, configFilePath); + + return ActionResult.Success; + } + + /// + /// Updates the port in the config file. + /// + /// The port to have Redis listen at + /// The path to the Redis config file + 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."); + } + } + } +} diff --git a/msvs/msi/RedisWindowsX64.CustomActions/Properties/AssemblyInfo.cs b/msvs/msi/RedisWindowsX64.CustomActions/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..4e5dfdc2 --- /dev/null +++ b/msvs/msi/RedisWindowsX64.CustomActions/Properties/AssemblyInfo.cs @@ -0,0 +1,34 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("RedisWindowsX64.CustomActions")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyCompany("MSOpenTech")] +[assembly: AssemblyProduct("RedisWindowsX64.CustomActions")] +[assembly: AssemblyCopyright("Copyright © MSOpenTech 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("afda0233-dacd-4bbe-89ce-19cdb9000561")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/msvs/msi/RedisWindowsX64.CustomActions/RedisWindowsX64.CustomActions.csproj b/msvs/msi/RedisWindowsX64.CustomActions/RedisWindowsX64.CustomActions.csproj new file mode 100644 index 00000000..090fe997 --- /dev/null +++ b/msvs/msi/RedisWindowsX64.CustomActions/RedisWindowsX64.CustomActions.csproj @@ -0,0 +1,66 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {A917027E-D229-46C9-B969-1F4CE7D5D2CA} + Library + Properties + RedisWindowsX64.CustomActions + RedisWindowsX64.CustomActions + v2.0 + 512 + $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.CA.targets + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + + + + + + True + + + + + + + + + + \ No newline at end of file diff --git a/msvs/msi/RedisWindowsX64/Components/DocumentationComponents.wxs b/msvs/msi/RedisWindowsX64/Components/DocumentationComponents.wxs new file mode 100644 index 00000000..2045e849 --- /dev/null +++ b/msvs/msi/RedisWindowsX64/Components/DocumentationComponents.wxs @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msvs/msi/RedisWindowsX64/Components/FileComponents.wxs b/msvs/msi/RedisWindowsX64/Components/FileComponents.wxs new file mode 100644 index 00000000..24690775 --- /dev/null +++ b/msvs/msi/RedisWindowsX64/Components/FileComponents.wxs @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msvs/msi/RedisWindowsX64/Components/WindowsServiceComponents.wxs b/msvs/msi/RedisWindowsX64/Components/WindowsServiceComponents.wxs new file mode 100644 index 00000000..ead7b059 --- /dev/null +++ b/msvs/msi/RedisWindowsX64/Components/WindowsServiceComponents.wxs @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msvs/msi/RedisWindowsX64/Dialogs/CustomInstallDir.wxs b/msvs/msi/RedisWindowsX64/Dialogs/CustomInstallDir.wxs new file mode 100644 index 00000000..6fa5510e --- /dev/null +++ b/msvs/msi/RedisWindowsX64/Dialogs/CustomInstallDir.wxs @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + "1"]]> + + 1 + + NOT Installed + Installed AND PATCH + + 1 + LicenseAccepted = "1" + + 1 + 1 + NOT WIXUI_DONTVALIDATEPATH + + WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1" + 1 + 1 + + "1"]]> + 1 + 1 + + NOT Installed + Installed AND NOT PATCH + Installed AND PATCH + + 1 + + 1 + 1 + 1 + + + + + + + \ No newline at end of file diff --git a/msvs/msi/RedisWindowsX64/Dialogs/FirewallDialog.wxs b/msvs/msi/RedisWindowsX64/Dialogs/FirewallDialog.wxs new file mode 100644 index 00000000..811fba3a --- /dev/null +++ b/msvs/msi/RedisWindowsX64/Dialogs/FirewallDialog.wxs @@ -0,0 +1,25 @@ + + + + + + + + + 1 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msvs/RedisWindowsX64/redis_background.jpg b/msvs/msi/RedisWindowsX64/Images/redis_background.jpg similarity index 100% rename from msvs/RedisWindowsX64/redis_background.jpg rename to msvs/msi/RedisWindowsX64/Images/redis_background.jpg diff --git a/msvs/RedisWindowsX64/top_banner.jpg b/msvs/msi/RedisWindowsX64/Images/top_banner.jpg similarity index 100% rename from msvs/RedisWindowsX64/top_banner.jpg rename to msvs/msi/RedisWindowsX64/Images/top_banner.jpg diff --git a/msvs/RedisWindowsX64/License.rtf b/msvs/msi/RedisWindowsX64/License.rtf similarity index 100% rename from msvs/RedisWindowsX64/License.rtf rename to msvs/msi/RedisWindowsX64/License.rtf diff --git a/msvs/msi/RedisWindowsX64/Product.wxs b/msvs/msi/RedisWindowsX64/Product.wxs new file mode 100644 index 00000000..c74b3669 --- /dev/null +++ b/msvs/msi/RedisWindowsX64/Product.wxs @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msvs/RedisWindowsX64/RedisWindowsX64.wixproj b/msvs/msi/RedisWindowsX64/RedisWindowsX64.wixproj similarity index 67% rename from msvs/RedisWindowsX64/RedisWindowsX64.wixproj rename to msvs/msi/RedisWindowsX64/RedisWindowsX64.wixproj index ae167c6b..c2eaa025 100644 --- a/msvs/RedisWindowsX64/RedisWindowsX64.wixproj +++ b/msvs/msi/RedisWindowsX64/RedisWindowsX64.wixproj @@ -22,12 +22,27 @@ obj\$(Configuration)\ -arch x64 + + Debug + -arch x64 + bin\$(Platform)\$(Configuration)\ + obj\$(Platform)\$(Configuration)\ + + + -arch x64 + bin\$(Platform)\$(Configuration)\ + obj\$(Platform)\$(Configuration)\ + - + + + + + - + RedisBenchmark {b00d4bb5-44de-405e-839c-d16f547006cf} True @@ -35,7 +50,7 @@ Binaries;Content;Satellites INSTALLFOLDER - + RedisCheckAof {a65c2cd6-72a3-441a-aea3-d754bea9a86a} True @@ -43,7 +58,7 @@ Binaries;Content;Satellites INSTALLFOLDER - + RedisCheckDump {52193a97-d010-41d6-bf2b-33e8e764e308} True @@ -51,7 +66,7 @@ Binaries;Content;Satellites INSTALLFOLDER - + RedisCli {392bbb91-3934-4a56-af42-65c5728311e8} True @@ -59,7 +74,7 @@ Binaries;Content;Satellites INSTALLFOLDER - + RedisServer {46842776-68a5-ec98-6a09-1859bbfc73aa} True @@ -67,6 +82,14 @@ Binaries;Content;Satellites INSTALLFOLDER + + RedisWindowsX64.CustomActions + {a917027e-d229-46c9-b969-1f4ce7d5d2ca} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + @@ -83,9 +106,14 @@ + + - - + + + + +