Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.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
C# Wix安装程序:有条件安装windows服务或独立应用程序_C#_Installation_Wix_Windows Installer_Wix3 - Fatal编程技术网

C# Wix安装程序:有条件安装windows服务或独立应用程序

C# Wix安装程序:有条件安装windows服务或独立应用程序,c#,installation,wix,windows-installer,wix3,C#,Installation,Wix,Windows Installer,Wix3,我有一个带引导程序的wix安装项目,我想安装一个可以作为Windows服务或独立应用程序运行的exe 我准备了一个用户界面,用户可以选择安装哪个版本。 除了一件事:卸载,一切都正常工作 当我作为widnows服务安装时,exe文件保存在INSTALLATION_DIR中,服务将被安装为runned(使用services.msc进行检查) 当我卸载它并作为独立版本再次安装时,它会从服务中卸载服务 但是问题出现了,当我尝试了几次(作为服务安装、卸载、作为应用程序安装、卸载)之后,在2-3次这样的循环

我有一个带引导程序的wix安装项目,我想安装一个可以作为Windows服务或独立应用程序运行的exe

我准备了一个用户界面,用户可以选择安装哪个版本。 除了一件事:卸载,一切都正常工作

当我作为widnows服务安装时,exe文件保存在INSTALLATION_DIR中,服务将被安装为runned(使用services.msc进行检查)

当我卸载它并作为独立版本再次安装时,它会从服务中卸载服务

但是问题出现了,当我尝试了几次(作为服务安装、卸载、作为应用程序安装、卸载)之后,在2-3次这样的循环之后,有些东西坏了。在下一次卸载过程中,文件将被删除,但.exe文件仍在安装目录中,并且服务不会从services.msc中删除

此处有条件安装:

<ComponentGroup Id="ServiceComponent" Directory="INSTALLFOLDER">
  <ComponentGroupRef Id="OtherBinariesWIthoutExeFile" />

  <Component Id="ExeService" Guid="{MY-GUID1}" SharedDllRefCount="yes">
    <Condition>USER_SELECTION="0"</Condition>
    <File
      Id="ExeServiceFile"
      Name="MyFile.exe"
      Source="Build\MyFile.exe"
      KeyPath="yes"
      Vital="yes">
    </File>
    <ServiceInstall
      Id="ServiceInstaller"
      Name="MyServiceName"
      Type="ownProcess"
      Start="auto"
      ErrorControl="critical"
      Account="LocalSystem"
      Vital="yes"/>
    <ServiceControl
      Id="ServiceController"
      Name="MyServiceName"
      Start="install"
      Stop="both"
      Remove="both"
      Wait="yes" />
  </Component>
  <Component Id="ExeApplication" Guid="{MY-GUID2}" SharedDllRefCount="yes">
    <Condition>USER_SELECTION="1"</Condition>
    <File
      Id="ExeApplication"
      Name="MyFile.exe"
      KeyPath="yes"
      Source="Build\MyFile.exe"
      Vital="yes">
    </File>
  </Component>

</ComponentGroup>

用户选择=“0”
用户选择=“1”
你知道这个配置有什么问题吗? 我在SharedDLRefCount中尝试了yes/no,结果是一样的。
我正在使用Wix v3.14.0.4118

我可能会使用两个不同的组件,其二进制名称不同:
MyApp.exe
MyAppService.exe
-换句话说,使用不同的名称包含相同的二进制文件两次-然后对整个组件进行条件设置-而不是添加仅包含服务元素构造的单独组件。MSI中的共享dll refcount在各种情况下都会导致不完整的卸载。