1

我想安装和启动Redis(对于 Windows)作为我们软件包的一部分。服务的安装和启动正常,但是在安装过程中出现错误,随后回滚,回滚后服务没有被移除。

谁能帮我找出我在这里做错了什么?另外,我是否也需要单独的删除命令,或者回滚也适用于卸载?

(像 [#fil5E85DBB2FFC8A2CFA55EDCADD8376C1F] 这样的值是使用 HeatDirectory 为 redis-server.exe 及其目录生成的 Id)

<!--Install Redis-->
<CustomAction Id="SetRedisInstall"
              Property="RedisInstall"
              Value="&quot;[#fil5E85DBB2FFC8A2CFA55EDCADD8376C1F]&quot; --service-install &quot;[dir13BD3F7531FC8E0F30BB51FAA1B1357F]redis.windows.conf&quot; --loglevel verbose" />
<CustomAction Id="RedisInstall"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec"
              Execute="deferred"
              Return="check"
              Impersonate="no"/>
<CustomAction Id="SetRedisStart" Property="RedisStart" Value="&quot;[#fil5E85DBB2FFC8A2CFA55EDCADD8376C1F]&quot; --service-start" />
<CustomAction Id="RedisStart"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec"
              Execute="deferred"
              Return="check"
              Impersonate="no"/>

<!--Rollback Redis-->
<CustomAction Id="SetRedisStop" Property="RedisStop" Value="&quot;[#fil5E85DBB2FFC8A2CFA55EDCADD8376C1F]&quot; --service-stop" />
<CustomAction Id="RedisStop"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec"
              Execute="rollback"
              Return="ignore"
              Impersonate="no"/>
<CustomAction Id="SetRedisRemove" Property="RedisRemove" Value="&quot;[#fil5E85DBB2FFC8A2CFA55EDCADD8376C1F]&quot; --service-uninstall" />
<CustomAction Id="RedisRemove"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec"
              Execute="ignore"
              Return="asyncWait"
              Impersonate="no"/>

<InstallExecuteSequence>
  <!--Install Redis-->
  <Custom Action="RedisInstall" Before="InstallFinalize">Not Installed</Custom>
  <Custom Action="SetRedisInstall" Before="RedisInstall">Not Installed</Custom>
  <Custom Action="RedisStart" After="RedisInstall">Not Installed</Custom>
  <Custom Action="SetRedisStart" Before="RedisStart">Not Installed</Custom>
  <!--Rollback Redis-->
  <Custom Action="SetRedisStop" Before="RedisStop"></Custom>
  <Custom Action="RedisStop" Before="RedisStart"></Custom>
  <Custom Action="RedisRemove" Before="RedisInstall"></Custom>
  <Custom Action="SetRedisRemove" Before="RedisRemove"></Custom>
</InstallExecuteSequence>

编辑我有组件

<Feature Id="Redis" Title="Redis" Level="1" >
  <ComponentGroupRef Id="RedisWxs"/>
</Feature>

现在也是服务部分:

<ServiceInstall Id="siRedisService" Description="Redis Service" DisplayName="Redis" Arguments="&quot;[dir13BD3F7531FC8E0F30BB51FAA1B1357F]redis.windows.conf&quot;" ErrorControl="normal" Name="Redis" Start="auto" Type="ownProcess" Vital="yes" Account="NT AUTHORITY\NetworkService"/>
<ServiceControl Id="scRedisService" Name="Redis" Start="install" Stop="both" Remove="both" Wait="yes" />

如何将服务添加到现有组件?

编辑 2

我禁用了自动采集并编辑了输出文件,从而解决了参考问题。我还是有Redis服务无法启动的问题。但是,当我只是在 cmd 中复制粘贴路径(包括配置文件)时,它工作得非常好......

这是代码

        <Component Id="cmp911C50BAA696496834114926A958787D" Guid="*">
            <File Id="fil5E85DBB2FFC8A2CFA55EDCADD8376C1F" KeyPath="yes" Source="$(var.RedisPath)\redis-server.exe" />
            <ServiceInstall Id="siRedisService" DisplayName="Redis" Arguments="--service-run redis.windows.conf --loglevel verbose" ErrorControl="normal" Name="Redis" Start="auto" Type="ownProcess" Vital="yes" Account="NT AUTHORITY\NetworkService"/>
            <ServiceControl Id="scRedisService" Name="Redis" Start="install" Stop="both" Remove="both" Wait="yes" />
        </Component>
        <Component Id="cmpFC38C2953561FABFFCF29CCEC52692E1" Guid="*">
            <File Id="filF5607FB03CD4B203C699DA14D17FF53B" KeyPath="yes" Source="$(var.RedisPath)\redis.windows.conf" />
        </Component>

编辑 3 - 工作解决方案

有一个权限问题,这就是我修复它的方法:

        <Component Id="cmp911C50BAA696496834114926A958787D" Guid="*">
            <File Id="fil5E85DBB2FFC8A2CFA55EDCADD8376C1F" KeyPath="yes" Source="$(var.RedisPath)\redis-server.exe" />
            <CreateFolder Directory="dir13BD3F7531FC8E0F30BB51FAA1B1357F">
              <util:PermissionEx User="NT AUTHORITY\NETWORKSERVICE" GenericAll="yes" />
            </CreateFolder>
            <ServiceInstall Id="siRedisService" DisplayName="Redis" Arguments="--service-run &quot;[#filF5607FB03CD4B203C699DA14D17FF53B]&quot;" ErrorControl="normal" Name="Redis" Start="auto" Type="ownProcess" Vital="yes" Account="NT AUTHORITY\NETWORKSERVICE"/>
            <ServiceControl Id="scRedisService" Name="Redis" Start="install" Stop="both" Remove="both" Wait="yes" />
        </Component>
4

1 回答 1

1

那肯定是很多自定义操作。我会摆脱他们。这是我滚动的方式:

<Component Id="redacted" Guid="redacted">
  <File Id="redacted" Source="$(var.SourceDir)\redis-server.exe" KeyPath="yes" />
  <ServiceInstall Id="siRedisService" Description="Redis Service" DisplayName="Redis" Arguments="--service-run redis.windows.conf --loglevel verbose" ErrorControl="normal" Name="Redis" Start="auto" Type="ownProcess" Vital="yes" Account="NT AUTHORITY\NetworkService"/>
  <ServiceControl Id="scRedisService" Name="Redis" Start="install" Stop="both" Remove="both" Wait="yes" />
</Component>
<Component Id="redacted" Guid="redacted">
  <File Id="redacted" Source="$(var.SourceDir)\redis.windows.conf" KeyPath="yes" />
</Component>

过去我已经说过很多次了……服务就是服务就是服务。除了 ServiceInstall 和 ServiceControl 以及偶尔的注册表条目之外的任何东西都是自我注册反模式疯狂的一种形式。服务可以用不同的语言编写并由不同的运行时托管,但它们与服务控制管理器 API 的交互都是相同的,一旦你解决了这些细节,MSI 可以本地处理它。

于 2014-08-28T17:37:29.820 回答