Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Wix和Windows服务问题_.net_Wcf_Windows Services_Wix - Fatal编程技术网

.net Wix和Windows服务问题

.net Wix和Windows服务问题,.net,wcf,windows-services,wix,.net,Wcf,Windows Services,Wix,我有一个Windows服务项目,其中包含一个WCF(selfhost)服务(两个dll文件和一个app.config),这将与Wix一起安装 <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="MyAppINSTALLDIR" Name="MyApp 5Service"> <Component Id="SampleServiceComponent" DiskId="1" Gui

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

<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>
我已经添加了对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>

<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>

<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>
这项工作到了一定程度,现在我有了一些问题:

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

    <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>
    
    要从输出中获取所有文件,我更改为此,但它不起作用:

    <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>
    
          <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>
    

    <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>
    
    
    
  • 要向安装程序中添加另一个文件,只需向安装程序中添加一个新的
    ,并将
    放入其中。您还需要将
    放到
    中的该组件中
  • 您可以在安装过程中使用
    元素修改app.config
  • 要向安装程序中添加另一个文件,只需向安装程序中添加一个新的
    ,并将
    放入其中。您还需要将
    放到
    中的该组件中
  • 您可以在安装过程中使用
    元素修改app.config

  • 您使用的是哪个版本的WiX?您使用的是哪个版本的WiX?谢谢,请参阅我的Edit1,我是否可以以类似的方式从输出中添加所有文件,或者我是否必须添加一个和一个?元素用于单个文件。你必须一个接一个地添加它们。WiX还附带了一个工具Heat,您可以使用它来获取一堆文件并生成适当的WiX源代码,您通常必须在运行Heat后对源代码进行处理,以使其正常工作。我建议逐个添加。这样我的Edit1就不会添加输出中的所有文件了?我了解到Heat在3.6中被禁用,在4.0更正之前不会被激活,它不会添加所有文件。此外,您仍然可以从命令行运行Heat,或者编写一些自定义包装程序来运行Heat并清理源代码。你不能像以前那样在VisualStudio项目上运行它。比如说,你可以在一个文件目录上运行它。谢谢,请参阅我的Edit1,我可以用类似的方式从输出中添加所有文件吗?或者我必须添加一个和一个吗?元素用于单个文件。你必须一个接一个地添加它们。WiX还附带了一个工具Heat,您可以使用它来获取一堆文件并生成适当的WiX源代码,您通常必须在运行Heat后对源代码进行处理,以使其正常工作。我建议逐个添加。这样我的Edit1就不会添加输出中的所有文件了?我了解到Heat在3.6中被禁用,在4.0更正之前不会被激活,它不会添加所有文件。此外,您仍然可以从命令行运行Heat,或者编写一些自定义包装程序来运行Heat并清理源代码。你不能像以前那样在VisualStudio项目上运行它。您可以在一个文件目录上运行它。