Wix和Windows服务问题

时间:2012-12-19 12:33:13

标签: .net wcf windows-services wix

我有一个Windows服务项目,其中包含一个WCF(自我主机)服务(几个dll文件和一个app.config),这将与Wix一起安装。

我添加了对Wix安装程序包的引用,这就是Product.wxs文件的样子:

<?xml version="1.0" encoding="UTF-8"?>

             

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="MyAppINSTALLDIR" Name="MyApp 5Service">
        <Component Id="SampleServiceComponent" DiskId="1" Guid="6f51c0f3-776c-4aec-a200-1f199352c6c3" Win64="yes">
          <File Id="MyApp.WindowsService.exe" Name="MyApp.WindowsService.exe" Source="$(var.MyApp .WindowsService.TargetDir)\MyApp.WindowsService.exe"/>
          <ServiceInstall Id="InstallMyAppService" DisplayName="MyAppService" Name="MyApp .WindowsService.exe" Description="MyApp 5 Service - För effektivare och enklare operationsplanering" Account="NetworkService" ErrorControl="normal" Start="demand" Type="ownProcess" Vital="yes" />
          <ServiceControl Id="ControlMyAppService" Name="MyApp5.WindowsService.exe" Stop="uninstall" Remove="uninstall" />
        </Component>
    </Directory>
</Directory>

<Property Id="WIXUI_INSTALLDIR" Value="MyAppINSTALLDIR" />
<UIRef Id="WixUI_InstallDir" />

<Feature Id="ProductFeature" Title="Wix_MyApp.WindowsService" Level="1">
  <ComponentRef Id="SampleServiceComponent" />
</Feature>
<Media Id="1" Cabinet="SampleServiceComponent.cab" EmbedCab="yes" />
</Product>

这项工作到了一定程度,现在我有了一些问题:

  1. 现在只包含我的主Windows服务exe文件?我需要它包含我的Selfhost的所有输出
  2. 我需要能够在安装之前设置Windows服务项目的app.config(它决定已安装服务的名称),是否可以在运行安装程序之前不使用压缩和设置文件,或者更容易在安装过程中获取信息并将其设置为app.config?
  3. 编辑1:

    要从输出中获取所有文件,我将其更改为此但不起作用? :

          <File Id="MyApp.WindowsService.Output"
            Name="$(var.MyApp.WindowsService.TargetFileName)"
            Source="$(var.MyApp.WindowsService.TargetPath)"
            KeyPath="yes" />
    
          <ServiceInstall Id="InstallMyAppService" DisplayName="MyAppService" Name="MyApp.WindowsService.exe" Description="MyApp 5 Service - För effektivare och enklare operationsplanering" Account="NetworkService" ErrorControl="normal" Start="demand" Type="ownProcess" Vital="yes" />
          <ServiceControl Id="ControlMyAppService" Name="MyApp.WindowsService.exe" Stop="uninstall" Remove="uninstall" />
    
    
        </Component>
    

1 个答案:

答案 0 :(得分:1)

  1. 要向安装程序添加其他文件,只需向安装程序添加新的<Component>并将<File>放入其中。您还需要将<ComponentRef>放入<Feature>
  2. 中的该组件
  3. 您可以在安装过程中使用<XmlConfig><XmlFile>元素修改app.config。