简体   繁体   English

Wix 安装程序 package 包含一个 C++ 生成器 Windows 服务

[英]Wix installer package containing a C++ Builder Windows service

I have a installation package made using the Wix toolset, that includes a service created with Embarcadero's C++ Builder.我有一个使用 Wix 工具集制作的 package 安装,其中包括使用 Embarcadero 的 C++ Builder 创建的服务。 ECB has a different syntax to register/unregister services under Windows if compared to Visual Studio C++/C#, I was not able to register the service through the regular Wix element <ServiceInstall> , the installer freezes during the service registration/unregistration. ECB 在 Windows 下注册/注销服务的语法与 Visual Studio C++/C# 相比,我无法通过常规 Wix 元素<ServiceInstall>注册服务,安装程序在服务注册/注销期间冻结。 I found a solution through the Wix Custom Actions .我通过 Wix Custom Actions找到了解决方案。 I created the following actions:我创建了以下操作:

    <CustomAction
        Id="LaunchApp_SrvInstall"
        Directory="INSTALLDIR"
        Impersonate="no"
        Execute="deferred"
        ExeCommand="&quot;[INSTALLDIR]ACService.exe&quot; /install /silent">
    </CustomAction>
    <CustomAction
        Id="LaunchApp_SrvUninstall"
        Directory="INSTALLDIR"
        Impersonate="no"
        Execute="deferred"
        ExeCommand="&quot;[INSTALLDIR]ACService.exe&quot; /uninstall /silent">
    </CustomAction>

    <InstallExecuteSequence>
        <Custom Action="LaunchApp_SrvInstall"   After="InstallFiles">NOT REMOVE</Custom>
        <Custom Action="LaunchApp_SrvUninstall" Before="RemoveFiles">REMOVE ~= "ALL"</Custom>
    </InstallExecuteSequence>

With the syntax above, during the package install, after the files are copied to the installation directory I have the service registered, and if I'm uninstalling the package the service is unregistered before the installed files are removed.使用上述语法,在 package 安装期间,将文件复制到安装目录后,我已注册服务,如果我要卸载 package,则在删除已安装文件之前取消注册服务。 In both cases it works perfectly.在这两种情况下,它都能完美运行。 The problem I'm facing happens when I try to update the software to a newer version, I have the scenario where the software and the service are running and the user tries to install the new MSI package to update the entire solution.当我尝试将软件更新到较新版本时,我面临的问题发生在软件和服务正在运行并且用户尝试安装新的 MSI package 以更新整个解决方案的情况下。 In that case, I have the following popup:在这种情况下,我有以下弹出窗口:

在此处输入图像描述

It seems that during the update process, the installer is trying to register the service twice, but I can't figure why.似乎在更新过程中,安装程序试图注册服务两次,但我不知道为什么。 Does anyone here already faced such situation?这里有没有人已经遇到过这种情况? Is there a way to configure the Custom Actions to work also during the package update?有没有办法在 package 更新期间配置自定义操作?

After the useful tips given in the comments, everything worked when I correlated the properties Name and DisplayName of the Embarcadero's IDE with the tags Name and DisplayName of the WiX installer project source, also, it was necessary to define the Arguments tag in <ServiceInstall> After the useful tips given in the comments, everything worked when I correlated the properties Name and DisplayName of the Embarcadero's IDE with the tags Name and DisplayName of the WiX installer project source, also, it was necessary to define the Arguments tag in <ServiceInstall>

在此处输入图像描述 在此处输入图像描述

That's it.而已。 Now I can handle my service using WiX.现在我可以使用 WiX 处理我的服务。 I'm quite confident the details above are also valid for the Delphi compiler.我很有信心上面的细节也适用于 Delphi 编译器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM