为什么热量导致我的Windows服务无法添加到Windows注册表/ Windows服务中

时间:2019-02-06 17:27:03

标签: c# wix

是否有任何原因会使Heat导致我的Windows服务无法添加到注册表中?我要在分支中进行两次不同的提交,两次提交之间的唯一区别是,最新的提交具有强大的功能,可以包含Wix引用的项目中的dll。

我已经使用msiexec和/ l * v浏览了日志,但是由于某种原因,那里的服务没有任何内容。

很抱歉,在某些代码上下文中,由于我出于安全原因必须删除某些关键字,所以xxx。这是我第一次处理热量,所以我不熟悉它,并且在查询了有关热量的问题后,我开始意识到文档也不太有用。

产品

<?xml version="1.0" encoding="UTF-8"?>
<!-- The name of the product -->
<?define Name = "xxx xxx Agent" ?>
<!-- The manufacturer, for setup package publisher and folder info -->
<?define Manufacturer = "xxx" ?>
<!-- The version number of this setup package-->
<?define Version = "1.0.0" ?>
<!-- UpgradeCode must be unique and not changed once the first version of the program is installed. -->
<?define UpgradeCode = "{145ED92C-BA1B-4257-8791-2337A012EEE7}" ?>
<?if $(var.Platform) = x64?>
<?define bitness = "(64 bit)"?>
<?define Win64 = "yes"?>
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?else ?>
<?define bitness = "(32 bit)"?>
<?define Win64 = "no"?>
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif ?>


<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="$(var.Name) $(var.bitness)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)" Version="$(var.Version)" Language="1033">
        <Package InstallerVersion="300" Compressed="yes"/>
        <Media Id="1" Cabinet="xxx.xxx.Agent.WindowsService.cab" EmbedCab="yes" />
        <MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="$(var.PlatformProgramFilesFolder)">
                <Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
                    <Directory Id="INSTALLFOLDER" Name="$(var.Name)" />
                </Directory>
            </Directory>
        </Directory>
        <DirectoryRef Id="INSTALLFOLDER">
            <Component Id="$(var.xxx.xxx.Agent.WindowsService.TargetFileName)" Win64="$(var.Win64)" Guid="FD94EF3C-4A0B-4102-AF1E-2A489B4DB7DF">
                <RemoveFile Id="ALLFILES" Name="*.*" On="both" />
                <ServiceInstall Id="ServiceInstaller"
                                Type="ownProcess"
                                Name="xxx.xxx.Agent.WindowsService"
                                Account="LocalSystem"
                                DisplayName="$(var.Name)"
                                Description="Deployment agent for xxx xxx"
                                Start="auto"
                                Interactive="yes"
                                Vital="yes"
                                ErrorControl="critical"
                                Arguments="/start xxx.xxx.Agent.WindowsService"/>
                <ServiceControl Id="ServiceUninstaller"
                                Name="xxx.xxx.Agent.WindowsService"
                                Stop="uninstall"
                                Remove="uninstall"
                                Wait="yes" />-
            </Component>
        </DirectoryRef>
        <Feature Id="MainApplication" Title="Main Application" Level="1">
            <ComponentRef Id="$(var.xxx.xxx.Agent.WindowsService.TargetFileName)" />
            <ComponentGroupRef Id="HeatGenerated"/>
        </Feature>
    </Product>
</Wix>

过滤器

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <xsl:output method="xml" indent="yes" />
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
    <xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.xml')]" use="@Id" />
    <xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.dll.config')]" use="@Id" />
    <xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id" />
    <xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, 'app.config')]" use="@Id" />
    <xsl:key name="service-search" match="wix:Component[wix:File/@Source = '$(var.xxx.xxx.xxx.WindowsService.TargetDir)\xxx.xxx.xxx.WindowsService.exe']" use="@Id" />
    <xsl:template match="wix:Component[key('service-search', @Id)]" />
    <xsl:template match="wix:ComponentRef[key('service-search', @Id)]" />
</xsl:stylesheet>

1 个答案:

答案 0 :(得分:0)

ServiceInstall的WiX文档中,我相信您需要一个File元素:

  

已安装的服务可执行文件将指向组件的KeyPath。因此,必须确保正确的可执行文件是此Component下的第一个子File元素,或将适当的File元素明确标记为KeyPath ='yes'。

所以我认为您只需要在服务Component下添加:

<File Id="WindowsServiceExe", KeyPath="yes" Source="$(var.xxx.xxx.xxx.WindowsService.TargetDir)\xxx.xxx.xxx.WindowsService.exe" />

还要查看您的转换,建议您为“过滤器”创建单独的键名,而不要重复使用service-search