diff --git a/TimberWinR.ServiceHost/Program.cs b/TimberWinR.ServiceHost/Program.cs index 0363468..9d9b190 100644 --- a/TimberWinR.ServiceHost/Program.cs +++ b/TimberWinR.ServiceHost/Program.cs @@ -2,11 +2,12 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; - +using System.Runtime.Remoting.Contexts; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using Microsoft.Win32; using TimberWinR.Outputs; using TimberWinR.ServiceHost; using TimberWinR.Inputs; @@ -46,8 +47,36 @@ namespace TimberWinR.ServiceHost hostConfigurator.SetDisplayName("TimberWinR"); hostConfigurator.SetDescription("TimberWinR using Topshelf"); hostConfigurator.SetServiceName("TimberWinR"); + + hostConfigurator.AfterInstall(() => + { + const string keyPath = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TimberWinR"; + const string keyName = "ImagePath"; + + var currentValue = Registry.GetValue(keyPath, keyName, "").ToString(); + if (!string.IsNullOrEmpty(currentValue)) + { + AddServiceParameter("-configFile", arguments.ConfigFile); + AddServiceParameter("-logLevel", arguments.LogLevel); + AddServiceParameter("-logDir", arguments.LogfileDir); + } + }); }); } + + private static void AddServiceParameter(string paramName, string value) + { + string keyPath = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TimberWinR"; + string keyName = "ImagePath"; + + string currentValue = Registry.GetValue(keyPath, keyName, "").ToString(); + + if (!string.IsNullOrEmpty(paramName) && !currentValue.Contains(string.Format("{0} ", paramName))) + { + currentValue += string.Format(" {0} \"{1}\"", paramName, value.Replace("\\\\", "\\")); + Registry.SetValue(keyPath, keyName, currentValue); + } + } } internal class Arguments diff --git a/TimberWinR.sln b/TimberWinR.sln index 0b2887d..e3eb21b 100644 --- a/TimberWinR.sln +++ b/TimberWinR.sln @@ -21,28 +21,58 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Installer", "Installer\Installer.vdproj", "{71EAE23D-FAC3-4141-9557-028FB96565F8}" +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "TimberWinR.Wix", "TimberWix\TimberWinR.Wix.wixproj", "{82A39B31-61EC-468D-AA71-0D949AC6528F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {4EF96A08-21DB-4178-BE44-70DAE594632C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4EF96A08-21DB-4178-BE44-70DAE594632C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4EF96A08-21DB-4178-BE44-70DAE594632C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {4EF96A08-21DB-4178-BE44-70DAE594632C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {4EF96A08-21DB-4178-BE44-70DAE594632C}.Debug|x86.ActiveCfg = Debug|Any CPU {4EF96A08-21DB-4178-BE44-70DAE594632C}.Release|Any CPU.ActiveCfg = Release|Any CPU {4EF96A08-21DB-4178-BE44-70DAE594632C}.Release|Any CPU.Build.0 = Release|Any CPU + {4EF96A08-21DB-4178-BE44-70DAE594632C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {4EF96A08-21DB-4178-BE44-70DAE594632C}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {4EF96A08-21DB-4178-BE44-70DAE594632C}.Release|x86.ActiveCfg = Release|Any CPU {2C0B4C56-0D63-4B89-852B-F9BFF4431F00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2C0B4C56-0D63-4B89-852B-F9BFF4431F00}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2C0B4C56-0D63-4B89-852B-F9BFF4431F00}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {2C0B4C56-0D63-4B89-852B-F9BFF4431F00}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2C0B4C56-0D63-4B89-852B-F9BFF4431F00}.Debug|x86.ActiveCfg = Debug|Any CPU {2C0B4C56-0D63-4B89-852B-F9BFF4431F00}.Release|Any CPU.ActiveCfg = Release|Any CPU {2C0B4C56-0D63-4B89-852B-F9BFF4431F00}.Release|Any CPU.Build.0 = Release|Any CPU + {2C0B4C56-0D63-4B89-852B-F9BFF4431F00}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {2C0B4C56-0D63-4B89-852B-F9BFF4431F00}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {2C0B4C56-0D63-4B89-852B-F9BFF4431F00}.Release|x86.ActiveCfg = Release|Any CPU {4410C95C-B22F-4B68-B132-84545AAA7A31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4410C95C-B22F-4B68-B132-84545AAA7A31}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4410C95C-B22F-4B68-B132-84545AAA7A31}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {4410C95C-B22F-4B68-B132-84545AAA7A31}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {4410C95C-B22F-4B68-B132-84545AAA7A31}.Debug|x86.ActiveCfg = Debug|Any CPU {4410C95C-B22F-4B68-B132-84545AAA7A31}.Release|Any CPU.ActiveCfg = Release|Any CPU {4410C95C-B22F-4B68-B132-84545AAA7A31}.Release|Any CPU.Build.0 = Release|Any CPU - {71EAE23D-FAC3-4141-9557-028FB96565F8}.Debug|Any CPU.ActiveCfg = Debug - {71EAE23D-FAC3-4141-9557-028FB96565F8}.Release|Any CPU.ActiveCfg = Release + {4410C95C-B22F-4B68-B132-84545AAA7A31}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {4410C95C-B22F-4B68-B132-84545AAA7A31}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {4410C95C-B22F-4B68-B132-84545AAA7A31}.Release|x86.ActiveCfg = Release|Any CPU + {82A39B31-61EC-468D-AA71-0D949AC6528F}.Debug|Any CPU.ActiveCfg = Debug|x86 + {82A39B31-61EC-468D-AA71-0D949AC6528F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {82A39B31-61EC-468D-AA71-0D949AC6528F}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {82A39B31-61EC-468D-AA71-0D949AC6528F}.Debug|x86.ActiveCfg = Debug|x86 + {82A39B31-61EC-468D-AA71-0D949AC6528F}.Debug|x86.Build.0 = Debug|x86 + {82A39B31-61EC-468D-AA71-0D949AC6528F}.Release|Any CPU.ActiveCfg = Release|x86 + {82A39B31-61EC-468D-AA71-0D949AC6528F}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {82A39B31-61EC-468D-AA71-0D949AC6528F}.Release|Mixed Platforms.Build.0 = Release|x86 + {82A39B31-61EC-468D-AA71-0D949AC6528F}.Release|x86.ActiveCfg = Release|x86 + {82A39B31-61EC-468D-AA71-0D949AC6528F}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TimberWix/Product.wxs b/TimberWix/Product.wxs new file mode 100644 index 0000000..de6a1c8 --- /dev/null +++ b/TimberWix/Product.wxs @@ -0,0 +1,72 @@ + + + + + default.json + c:\logs + Info + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOT Installed + NOT Installed + Installed + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TimberWix/TimberWinR.Wix.wixproj b/TimberWix/TimberWinR.Wix.wixproj new file mode 100644 index 0000000..155b292 --- /dev/null +++ b/TimberWix/TimberWinR.Wix.wixproj @@ -0,0 +1,60 @@ + + + + Debug + x86 + 3.8 + 1.1.0 + 82a39b31-61ec-468d-aa71-0d949ac6528f + 2.0 + TimberWinR-$(MSIVersionNumber) + Package + $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets + $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets + TimberWinR.Wix + + + bin\$(Configuration)\ + obj\$(Configuration)\ + Debug; + True + + + + + + + + + bin\$(Configuration)\ + obj\$(Configuration)\ + + + + + + + TimberWinR.ServiceHost + {2c0b4c56-0d63-4b89-852b-f9bff4431f00} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + + + + + + + + + + + \ No newline at end of file