有没有人有完整的wix配置示例来安装基于procrun的Java服务?

时间:2015-09-30 14:48:11

标签: wix windows-installer procrun

我一直致力于一个项目,我需要安装从Windows的Wix安装程序作为spring boot应用程序运行的Java服务。如果系统上已经全局安装了JRE实例,它应该自动检测,如果是,请使用它,否则,为此应用程序安装一个私有JRE。在寻找完整的解决方案并解决许多不同的问题后,我想出了一个有效的配置。它通过Wix手动安装服务,并设置procrun程序所需的所有注册表项,而不是使用procrun来安装服务。

我是网站的新手(作为提交者),但我会发布我创建的Wix XML作为答案。它并不完美,但希望能帮助其他人克服我必须跳过的障碍才能完成这项工作。

1 个答案:

答案 0 :(得分:5)

这是一个(汇总的)Wix xml,其中包含重要的部分。由于响应大小限制,我不得不总结一下。感谢许多Stack溢出答案,以帮助达到这一点。

<?xml version="1.0" encoding="utf-8"?>
<!--
# This comment is generated by WixEdit, the specific commandline
# arguments for the WiX Toolset are stored here.

candleArgs: 
lightArgs: "heimdalldemo.wixobj" -out "heimdalldemo.msi" -ext WixUtilExtension -ext WixUIExtension
-->
<!-- installation script for the Heimdall Data Access Platform, www.heimdalldata.com -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Heimdall Data Access Platform" Language="1033" Version="0.9.0.1" Manufacturer="Heimdall Data" UpgradeCode="98CE97B6-8E91-42F5-8C32-8F0F078433EC">
    <Package Description="Heimdall Data Server and Driver Installer" Comments="Heimdall Installer" InstallPrivileges="elevated" InstallScope="perMachine" InstallerVersion="200" Compressed="yes" Platform="x64" />
    <Media Id="1" Cabinet="simple.cab" EmbedCab="yes" />
    <?define ProductName = "Heimdall Data Access Platform" ?>
    <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
    <!-- Check some requirements ONLY on "install", but not on modify or uninstall. -->
    <Property Id="JAVA_CURRENT_VERSION64">
        <RegistrySearch Id="JRE_CURRENT_VERSION_REGSEARCH64" Root="HKLM" Key="SOFTWARE\JavaSoft\Java Runtime Environment" Name="CurrentVersion" Type="raw" Win64="yes" />
    </Property>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="$(var.PlatformProgramFilesFolder)">
            <Directory Id="DRIVERDIR" Name="Heimdall">
                <!-- driver components -->
            </Directory>
            <Directory Id="TRAFFICDIR" Name="Heimdall">
       <!-- traffic generator components -->
            </Directory>
            <Directory Id="SERVERDIR" Name="Heimdall">
                <Component Id="REGISTRY_A" DiskId="1" Guid="*">
                    <RegistryKey Root="HKLM" Key="SOFTWARE\Apache Software Foundation\Procrun 2.0\Heimdall\Parameters\Java" Action="createAndRemoveOnUninstall">
                        <RegistryValue Type="string" Name="Classpath" Value="[SERVERDIR]heimdallserver.jar" KeyPath="yes" />
                        <RegistryValue Type="string" Name="Jvm"     Value="auto" />
                        <RegistryValue Type="multiString" Action="append" Name="Options">
                           <MultiStringValue Type="multiString" Name="Options" Action="append">-Duser.dir=[SERVERDIR]</MultiStringValue>
                           <MultiStringValue Type="multiString" Name="Options" Action="append">-XX:+UseConcMarkSweepGC</MultiStringValue>
                           <MultiStringValue Type="multiString" Name="Options" Action="append">-XX:+CMSIncrementalPacing</MultiStringValue>
                           <MultiStringValue Type="multiString" Name="Options" Action="append">-XX:ParallelGCThreads=2</MultiStringValue>
                           <MultiStringValue Type="multiString" Name="Options" Action="append">-XX:+AggressiveOpts</MultiStringValue>
                        </RegistryValue>
                        <RegistryValue Type="integer" Name="JvmMs" Value="128" />
                        <RegistryValue Type="integer" Name="JvmMx" Value="512" />
                        <RegistryValue Type="integer" Name="JvmSs" Value="4000" />
                    </RegistryKey>
                    <RegistryKey Root="HKLM" Key="SOFTWARE\Apache Software Foundation\Procrun 2.0\Heimdall\Parameters\Log" Action="createAndRemoveOnUninstall">
                        <RegistryValue Type="string" Name="Path" Value="[SERVERDIR]log" />
                        <RegistryValue Type="string" Name="Level" Value="Error" />
                        <RegistryValue Type="string" Name="Prefix" Value="procrun.log" />
                        <RegistryValue Type="string" Name="StdError" Value="auto" />
                        <RegistryValue Type="string" Name="StdOutput" Value="auto" />
                    </RegistryKey>
                    <RegistryKey Root="HKLM" Key="SOFTWARE\Apache Software Foundation\Procrun 2.0\Heimdall\Parameters\Start" Action="createAndRemoveOnUninstall">
                        <RegistryValue Type="string" Name="Mode" Value="jvm" />
                        <RegistryValue Type="string" Name="Class" Value="com.heimdalldata.server.Bootstrap" />
            <RegistryValue Type="string" Name="WorkingPath" Value="[SERVERDIR]" />
                        <RegistryValue Type="string" Name="Method" Value="start" />
                        <RegistryValue Type="string" Name="Params" Value="start" />
                        <RegistryValue Type="string" Name="StdOutput" Value="auto" />
                    </RegistryKey>
                    <RegistryKey Root="HKLM" Key="SOFTWARE\Apache Software Foundation\Procrun 2.0\Heimdall\Parameters\Stop" Action="createAndRemoveOnUninstall">
                        <RegistryValue Type="string" Name="Mode" Value="jvm" />
                        <RegistryValue Type="string" Name="Class" Value="com.heimdalldata.server.Bootstrap" />
                        <RegistryValue Type="string" Name="Method" Value="stop" />
                        <RegistryValue Type="string" Name="Params" Value="stop" />
                        <RegistryValue Type="string" Name="StdOutput" Value="auto" />
                    </RegistryKey>
                    <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\Heimdall" Action="createAndRemoveOnUninstall">
                        <RegistryValue Type="string" Name="Description" Value="Heimdall Management and Logging Server" />
                        <RegistryValue Type="string" Name="DisplayName" Value="Heimdall" />
                        <RegistryValue Type="string" Name="ImagePath" Value="[SERVERDIR]heimdallserver.exe //RS//Heimdall" />
                        <RegistryValue Type="string" Name="DependsOnService" Value="Tcpip Afd" />
                        <RegistryValue Type="string" Name="ObjectName" Value="LocalSystem" />
                        <RegistryValue Type="integer" Name="ErrorControl" Value="1" />
                        <RegistryValue Type="integer" Name="Start" Value="2" />
                        <RegistryValue Type="integer" Name="Type" Value="16" />
                    </RegistryKey>
                    <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\Heimdall\Parameters" Action="createAndRemoveOnUninstall">
                        <RegistryValue Type="string" Name="Test" Value="Pass" />
                    </RegistryKey>
                </Component>
                <Component Id="REGISTRY_B" DiskId="1" Guid="*">
                    <RegistryKey Root="HKLM" Key="SOFTWARE\Apache Software Foundation\Procrun 2.0\Heimdall\Parameters\Java" Action="createAndRemoveOnUninstall">
                        <RegistryValue Type="string" Name="JavaHome" Value="[SERVERDIR]jre6" />
            <RegistryValue Type="string" Name="Jvm"     Value="[SERVERDIR]jre6\bin\server\jvm.dll" />
                    </RegistryKey>
                </Component>

                <Component Id="HEIMDALLSERVER64.EXE" DiskId="1" Guid="*"> <!-- this is the renamed procrun 64 bit executable -->
                    <File Id="HEIMDALLSERVER64.exe" Name="heimdallserver.exe" Source="c:\heimdall\heimdallserver64.exe" />
                    <ServiceInstall Id="HEIMDALLSERVER64" Type="ownProcess" Name="Heimdall" DisplayName="Heimdall" Description="Heimdall Management and Logging Server" Start="auto" Account="[SERVICEACCOUNT]" Password="[SERVICEPASSWORD]" ErrorControl="normal" Arguments=" //RS//Heimdall" />
                    <ServiceControl Id="StartService64" Start="install" Stop="both" Remove="uninstall" Name="Heimdall" Wait="no" />
                </Component>
            </Directory>
        </Directory>
    </Directory>
    <Feature Id="Server" Title="Heimdall Server" Level="1" ConfigurableDirectory="SERVERDIR">
        <ComponentRef Id="REGISTRY_A" />
        <!-- all server components -->
        <Feature Id="Configuration" Title="Example Configuration" Level="1" ConfigurableDirectory="CONFIG">
            <!-- all configuration components -->
        </Feature>
        <Feature Id="Drivers" Title="Driver Library" Level="1" ConfigurableDirectory="CONFIG">
       <!-- all driver feature components -->
        </Feature>
    </Feature>
    <Feature Id="Driver" Title="Heimdall Driver" Level="1" ConfigurableDirectory="DRIVERDIR">
        <!-- driver component -->
        <Feature Id="Libraries" Title="Grid API Libraries" Level="6" ConfigurableDirectory="LIBDIR">
            <!-- all library components -->
        </Feature>
    </Feature>

    <Feature Id="JRE" Title="Private JRE" Level="1" ConfigurableDirectory="SERVERDIR">
        <Condition Level="6">JAVA_CURRENT_VERSION64 &gt;= "1.6"</Condition>
    <ComponentRef Id="REGISTRY_B" />
    <!-- all JRE file components -->
    </Feature>
    <UI />
    <UIRef Id="WixUI_Mondo" />
    <!-- custom dialog (welcome and completion dialogs)  493x312 -->
    <WixVariable Id="WixUIDialogBmp" Value="C:\heimdall\banner.bmp" />
    <!-- custom logo (top bar)  493x58 -->
    <WixVariable Id="WixUIBannerBmp" Value="C:\heimdall\logo.bmp" />
    <!-- custom license agreement -->
    <!-- <WixVariable Id="WixUILicenseRtf" Value="c:\heimdall\license.rtf" /> -->
    <!-- call localhost:8087 on exit of installer when installing -->
    <Property Id="MyURL"><![CDATA[http://localhost:8087/]]></Property>
    <CustomAction Id="SetOpenURL" Property="WixShellExecTarget" Value="[MyURL]" />
    <CustomAction Id="OpenURL" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" Return="ignore" />
    <InstallExecuteSequence>
        <!-- Launch webpage during full uninstall, but not upgrade -->
        <Custom Action="SetOpenURL" After="InstallFinalize"><![CDATA[&Server=3 AND UILevel > 2 AND NOT Installed]]></Custom>
        <Custom Action="OpenURL" After="SetOpenURL"><![CDATA[&Server=3 AND UILevel > 2 AND NOT Installed]]></Custom>
    </InstallExecuteSequence>
</Product>
</Wix>