Wix窗口服务只复制安装文件夹中的exe文件而不是所有依赖项

时间:2016-05-09 13:30:48

标签: service wix window

我是wix的新手,并创建了一个窗口服务。我已经创建了我的服务并成功添加了窗口服务,但是当我运行它时由于错误而停止。

    <?xml version="1.0" encoding="UTF-8"?>
<?define Name = "New Window Service" ?>
<?define Manufacturer = "GAT" ?>
<?define UpgradeCode = "{0d4fb541-bb66-4df8-bdab-893564e191fc}" ?>

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
     xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
       >
  <Product Id="*" Name="$(var.Name)" Manufacturer="$(var.Manufacturer)" Version="1.0.0.0" UpgradeCode="$(var.UpgradeCode)"  Language="1033">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <Media Id="1" Cabinet="GAT.GATAC.ServiceLayer.WindowsServiceHost.cab" EmbedCab="yes" />
    <MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
          <Directory Id="INSTALLFOLDER" Name="$(var.Name)" />
        </Directory>
      </Directory>
    </Directory>
    <DirectoryRef Id="INSTALLFOLDER">
      <Component Id="$(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetFileName)">
        <CreateFolder />
        <File Id="$(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetFileName)" Source="D:\Projects\GATAC\GAT.GATAC.ServiceLayer.WindowsServiceHost\bin\Release\GAT.GATAC.ServiceLayer.WindowsServiceHost.exe" KeyPath="yes"  Vital="yes" />
        <File Id="GAT.GATAC.ServiceLayer.WindowsServiceHost.exe.config"
                                  Name="MyProduct.exe.config"
                                  Source="D:\Projects\GATAC\GAT.GATAC.ServiceLayer.WindowsServiceHost\bin\Release\GAT.GATAC.ServiceLayer.WindowsServiceHost.exe.config"
                                  Vital="yes"
                                  KeyPath="no"
                                  DiskId="1" />
        <RemoveFile Id="ALLFILES" Name="*.*" On="both" />
        <util:XmlFile Id="ModifyServiceLocation" Action="setValue" ElementPath="/configuration/connectionStrings/add[\[]@name='DefaultConnection'[\]]/@connectionString" File="D:\Projects\GATAC\GAT.GATAC.ServiceLayer.WindowsServiceHost\bin\Release\GAT.GATAC.ServiceLayer.WindowsServiceHost.exe.config" Value="Data Source=[DB_SERVER];Initial Catalog=[DB_DATABASE];User Id=[DB_USER];Pwd=[DB_PASSWORD]"/>

        <ServiceInstall Id="ServiceInstaller"
                        Type="ownProcess"
                        Name="GAT.GATAC.ServiceLayer.WindowsServiceHost"
                        DisplayName="$(var.Name)"
                        Description="A Test Service that logs dummy text on an interval to a text file."
                        Start="auto"
                        ErrorControl="normal"
                        />
        <ServiceControl Id="ServiceInstaller"
                    Stop="both"
                    Remove="both"
                    Name="GAT.GATAC.ServiceLayer.WindowsServiceHost"
                    Wait="yes" />
      </Component>
    </DirectoryRef>
    <Feature Id="MainApplication" Title="Main Application" Level="1">
      <ComponentRef Id="$(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetFileName)" />
    </Feature>
  </Product>
</Wix>

当我在安装服务文件夹中看到只有exe文件时,如何在我的代码所在的文件夹中复制窗口服务的所有依赖项。当我在安装文件夹中手动复制文件时,它工作。我需要收获< / p>

1 个答案:

答案 0 :(得分:3)

是的,您需要在wxs中包含所有文件作为要安装的组件。

如果您有一些依赖项,您可以自己将它们添加为文件组件。如果有很多文件考虑使用heat来为你生成wxs文件,你可以将文件元素复制到你的wxs代码中。如果文件依赖关系可能经常更改,请考虑使用heat来始终生成wx并将其作为链接文件包含在主安装程序项目中。

理想情况下,所有依赖项都包含在GAT.GATAC.ServiceLayer.WindowsServiceHost项目的bin文件夹中,因此您只需使用$(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetDir)DependencyFileName作为源文件。

相关问题