Added Wix based installer

This commit is contained in:
Eric Fontana
2014-08-08 14:12:52 -04:00
parent 7dac747365
commit 226091c1f4
4 changed files with 195 additions and 4 deletions

View File

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

View File

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

72
TimberWix/Product.wxs Normal file
View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="TimberWinR" Language="1033" Version="1.0.0.0" Manufacturer="Vistaprint" UpgradeCode="5c2b6a95-34d5-4131-8fb0-5c97214df942">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<Property Id="CONFIGFILE">default.json</Property>
<Property Id="LOGDIR">c:\logs</Property>
<Property Id="LOGLEVEL">Info</Property>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="TimberWinR" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="TimberWinR" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="ProductComponent" Guid="1BDEC5F3-5E9F-4E2E-8B1B-30E7968A99E1">
<File Id="TimberWinR.ServiceHost.exe" Name="$(var.TimberWinR.ServiceHost.TargetFileName)" Source="$(var.TimberWinR.ServiceHost.TargetPath)" />
<File Id="TimberWinR.ServiceHost.exe.config" Source="$(var.TimberWinR.ServiceHost.TargetDir)\TimberWinR.ServiceHost.exe.config" />
<File Id="Interop.MSUtil.dll" Source="$(var.TimberWinR.ServiceHost.TargetDir)\Interop.MSUtil.dll" />
<File Id="csredis.dll" Source="$(var.TimberWinR.ServiceHost.TargetDir)\csredis.dll" />
<File Id="Newtonsoft.Json.dll" Source="$(var.TimberWinR.ServiceHost.TargetDir)\Newtonsoft.Json.dll" />
<File Id="Nlog.dll" Source="$(var.TimberWinR.ServiceHost.TargetDir)\Nlog.dll" />
<File Id="RestSharp.dll" Source="$(var.TimberWinR.ServiceHost.TargetDir)\RestSharp.dll" />
<File Id="RapidRegex.Core.dll" Source="$(var.TimberWinR.ServiceHost.TargetDir)\RapidRegex.Core.dll" />
<File Id="TimberWinR.dll" Source="$(var.TimberWinR.ServiceHost.TargetDir)\TimberWinR.dll" />
<File Id="Topshelf.dll" Source="$(var.TimberWinR.ServiceHost.TargetDir)\Topshelf.dll" />
</Component>
</ComponentGroup>
<InstallExecuteSequence>
<Custom Action='ManagedInstall' After="InstallFiles">NOT Installed</Custom>
<Custom Action='ManagedInstall2' After="ManagedInstall">NOT Installed</Custom>
<Custom Action='ManagedUnInstall' Before="RemoveFiles">Installed</Custom>
</InstallExecuteSequence>
<CustomAction Id="ManagedInstall"
Directory="INSTALLFOLDER"
Impersonate="yes"
Execute="deferred"
ExeCommand='"[INSTALLFOLDER]TimberWinR.ServiceHost.exe" install --autostart -configFile "[CONFIGFILE]" -logDir "[LOGDIR]" -logLevel "[LOGLEVEL]"'
Return='check'>
</CustomAction>
<CustomAction Id="ManagedInstall2"
Directory="INSTALLFOLDER"
Impersonate="yes"
Execute="deferred"
ExeCommand='"[INSTALLFOLDER]TimberWinR.ServiceHost.exe" start'
Return='check'>
</CustomAction>
<CustomAction Id="ManagedUnInstall"
Directory="INSTALLFOLDER"
Impersonate="yes"
Execute="deferred"
ExeCommand='"[INSTALLFOLDER]TimberWinR.ServiceHost.exe" uninstall'
Return='check'>
</CustomAction>
</Fragment>
</Wix>

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.8</ProductVersion>
<MSIVersionNumber>1.1.0</MSIVersionNumber>
<ProjectGuid>82a39b31-61ec-468d-aa71-0d949ac6528f</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>TimberWinR-$(MSIVersionNumber)</OutputName>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<Name>TimberWinR.Wix</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;</DefineConstants>
<VerboseOutput>True</VerboseOutput>
<WixVariables>
</WixVariables>
<CompilerAdditionalOptions>
</CompilerAdditionalOptions>
<LinkerAdditionalOptions>
</LinkerAdditionalOptions>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TimberWinR.ServiceHost\TimberWinR.ServiceHost.csproj">
<Name>TimberWinR.ServiceHost</Name>
<Project>{2c0b4c56-0d63-4b89-852b-f9bff4431f00}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
<PropertyGroup>
<PostBuildEvent />
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent />
</PropertyGroup>
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>