In a previous blog, the OUT-OF-PROCESS Semantic Logging service was installed from hand. (Power shell script and xml configuration).
Enterprise Library 6, Semantic Logging, Part 2, OUT-OF-PROCESS
A typical end user cannot be expected to do this. It would be better, if an msi could be created so that a fully pre-configured service can be deployed as an msi. This msi will be a silent installer. The service can then be automatically deployed from a separate server or any type of end user can install it. (Single click and the service runs)
To create the msi, the WiX toolset will be used.
The WiX toolset must be installed on the development PC. (just for msi creation).
http://wix.codeplex.com/releases/view/99514 (WiX37.exe)
Once the project has been created, add the following code to the wxs file (Also rename the wxs file to SlabOutOfProcess.wxs)
<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> <Product Id="*" Name="damienbod SLAB out-of-process" Language="1033" Version="1.0.0.0" Manufacturer="damienbod" UpgradeCode="2e31d6a9-9e73-40d0-b714-ef071e546f61"> <Package Id="*" InstallerVersion="305" InstallScope="perMachine" Compressed="yes" /> <MediaTemplate /> <Property Id="INSTALLPATH">C:\damienbod</Property> <!-- Installationsbeschränkungen prüfen. --> <PropertyRef Id="NETFRAMEWORK40FULL" /> <Condition Message="!(loc.ErrorNet40NotInstalled)"> <![CDATA[Installed OR NETFRAMEWORK40FULL]]> </Condition> <Condition Message="!(loc.ErrorAdministrativePriviledgesRequired)"> <![CDATA[Privileged]]> </Condition> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id='ProgramFilesFolder' Name='PFiles'> <Directory Id='damienbod' Name='damienbod'> <Directory Id='INSTALLPATH' Name='SlabOutOfProcess' > </Directory> </Directory> </Directory> </Directory> <DirectoryRef Id='INSTALLPATH'> <Directory Id='INSTALLDIR_SlabOutOfProcess' Name='SlabOutOfProcess' /> </DirectoryRef> <Feature Id="ProductFeature" Title="WiXServiceSilentInstaller" Level="1"> <ComponentGroupRef Id="SlabOutOfProcessGroup" /> <ComponentRef Id="SlabOutOfProcessRegisterComponent" /> </Feature> <Component Id='SlabOutOfProcessRegisterComponent' Guid='ABB394C2-21A1-4132-AB7D-95CBBABE5B0A' Directory='INSTALLDIR_SlabOutOfProcess' Feature='ProductFeature' DiskId='1'> <File Id="SlabOutOfProcessExe" Name="SemanticLogging-svc.exe" Source="..\outOfProc\SemanticLogging-svc.exe" KeyPath="yes" DiskId="1"/> <ServiceInstall Id='SlabOutOfProcessExeServiceInstall' Name='Enterprise Library Semantic Logging Service' Description='damienbod SLAB out-of-process service' ErrorControl='normal' Start='auto' Type='ownProcess' Vital='yes' /> <ServiceControl Id='SlabOutOfProcessExeServiceInstall' Name='Enterprise Library Semantic Logging Service' Start='install' Remove='uninstall' Wait='yes' /> <CreateFolder /> </Component> <!-- Sicherstellen das Upgrades erlaubt sind. --> <MajorUpgrade Schedule="afterInstallInitialize" AllowDowngrades="no" DowngradeErrorMessage="!(loc.ErrorNewerVersionInstalled)" AllowSameVersionUpgrades="yes" /> </Product> </Wix>
Add a language file the the project and add the following.
(These are just de translations, maybe you have just english and this file is not required.)
(Also rename the wxl file to SlabOutOfProcess.de-DE.wxl)
<?xml version="1.0" encoding="utf-8"?> <WixLocalization Culture="de-DE" xmlns="http://schemas.microsoft.com/wix/2006/localization"> <!-- Texte für Fehler --> <String Id="ErrorNet40NotInstalled">[ProductName] benötigt Microsoft .Net 4.0 (Vollständiges Profil).</String> <String Id="ErrorNewerVersionInstalled">Eine neuere Version von [ProductName] ist bereits installiert. Setupvorgang wird abgebrochen. Bitte entfernen Sie zuerst die neuere Version und starten Sie anschliessend die Installation neu.</String> <String Id="ErrorAdministrativePriviledgesRequired">Sie müssen als Administrator angemeldet sein um dieses Produkt zu installieren.</String> <String Id="ErrorWindowsServer2008OrHigherRequired">[ProductName] benötigt mindestens Microsoft Windows Server 2008.</String> </WixLocalization>
Unload the proj file and click edit. Add the following (required for the WiX Harvest)
<?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.7</ProductVersion> <ProjectGuid>dd771dc3-9b79-41da-8fa6-3d84631b7805</ProjectGuid> <SchemaVersion>2.0</SchemaVersion> <OutputName>damienbod.SLAB.installer</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> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> <OutputPath>bin\$(Configuration)\</OutputPath> <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath> <DefineConstants>Debug;SlabOutOfProcessRegisterComponent=..\outOfProc</DefineConstants> <SuppressValidation>True</SuppressValidation> <SuppressIces>ICE34</SuppressIces> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <OutputPath>bin\$(Configuration)\</OutputPath> <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath> <DefineConstants>SlabOutOfProcessRegisterComponent=..\outOfProc</DefineConstants> <SuppressValidation>True</SuppressValidation> <SuppressIces>ICE34</SuppressIces> </PropertyGroup> <ItemGroup> <Compile Include="SlabOutOfProcess.wxs" /> </ItemGroup> <ItemGroup> <WixExtension Include="WixVSExtension"> <HintPath>$(WixExtDir)\WixVSExtension.dll</HintPath> <Name>WixVSExtension</Name> </WixExtension> <WixExtension Include="WixUtilExtension"> <HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath> <Name>WixUtilExtension</Name> </WixExtension> <WixExtension Include="WixUIExtension"> <HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath> <Name>WixUIExtension</Name> </WixExtension> <WixExtension Include="WixNetFxExtension"> <HintPath>$(WixExtDir)\WixNetFxExtension.dll</HintPath> <Name>WixNetFxExtension</Name> </WixExtension> </ItemGroup> <ItemGroup> </ItemGroup> <ItemGroup> <HarvestDirectory Include="..\outOfProc\"> <AutogenerateGuids>true</AutogenerateGuids> <ComponentGroupName>SlabOutOfProcessGroup</ComponentGroupName> <DirectoryRefId>INSTALLDIR_SlabOutOfProcess</DirectoryRefId> <SuppressCom>true</SuppressCom> <SuppressRegistry>true</SuppressRegistry> <SuppressRootDirectory>true</SuppressRootDirectory> <PreprocessorVariable>var.SlabOutOfProcessRegisterComponent</PreprocessorVariable> <Visible>false</Visible> <!--<Transforms>IgnoreFilesInHarvesting.xslt</Transforms>--> </HarvestDirectory> </ItemGroup> <Import Project="$(WixTargetsPath)" /> <!-- 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>
The harvest is configured to select all files in the outOfProc folder
Now the solution should build. When the produced msi is clicked, the SLAB service will be installed and running. The Program is now in the Programs menu and can easily be installed or uninstalled using the windows menu.
And the service is also running:
Code: https://github.com/damienbod/WiXServiceSilentSLABInstaller.git
This project can now be used for any deployment. Before the WiX project is built, just change the SemanticLogging-svc.xml (in outOfProc folder) to match your EventSource classes.
Note the database must be also installed. This is not included in the WiX project. This is because the database usually comes with your business application.
Links:
[…] https://damienbod.com/2013/08/20/creating-a-silent-msi-for-semantic-logging-out-of-process-service-us… […]