【问题标题】:Install a windows service with InstallUtil.exe command during an installation在安装过程中使用 InstallUtil.exe 命令安装 Windows 服务
【发布时间】:2020-04-03 18:46:05
【问题描述】:

我在Visual Studio Solution 中有一个Console Application 项目。此应用程序(此处称为 semplicity MyApplication.exe)只不过是 WCF 服务的主机。

我需要一个安装程序来在目标机器上安装我的应用程序,所以我下载了Microsoft Visual Studio Installer Projects 扩展。我收集了所有要复制到应用程序文件夹中的文件,但我希望安装程序甚至将我的服务注册为 Windows 服务。

为此,我导入了InstallUtil.exe,如下图所示。我创建了嵌套的额外文件夹(Windows 文件夹 -> Microsoft.NET -> Framework64 -> v4.030319)以反映目标环境的实际结构。

然后我在Commit 节点下创建了这样的Custom Action

以下Arguments:

“[TARGETDIR]MyApplication.exe”

我尝试了生成的设置,发现所有文件都已复制,但未安装服务(我在 MSC 列表中没有看到它)。

所以,在我的问题下面:

  • 我在哪里做错了什么?
  • 有没有我可以查看的日志?
  • 如果之前已经安装了该服务,我可以通过何种方式卸载它?
  • 坦率地说,我希望有更多可定制的东西。例如,与我的应用程序相关的附加复选框或用户可以在安装时管理的东西。如果我的App.config 包含 KeyValue [Server="localhost"] 是否可以在安装时自定义它,并向用户弹出一个弹出窗口:“您的服务器在哪里?”并使用提示的信息更新我的配置文件用户?

【问题讨论】:

    标签: c# installation installutil


    【解决方案1】:

    限制Visual Studio Installer Projects have many limitations (short version, Chris Painter)。

    替代工具There are many other tools, some of which are free


    WiX 工具包:WiX 工具包是免费和开源的。下面是两个示例,说明如何在不需要运行自定义的情况下安装服务 操作(安装服务的能力是 MSI 内置的,不需要 使用 InstallUtil.exe - the "say no" to unnecessary custom action campaign):


    链接

    【讨论】:

      【解决方案2】:

      也许这对处于类似情况的人有用。

      使用声明

      using System.Configuration.Install;
      

      正在安装

      ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });
      

      卸载

      ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });
      

      上面处理了您提到的 InstallUtil 的功能。

      文档

      ManagedInstallerClass.InstallHelper

      Documentation on InstallUtil

      该实用程序位于以下位置:

      Windows 系统上的 .NET 目录:

      • C:\Windows\Microsoft.NET\Framework\v \InstallUtil.exe
      • C:\Windows\Microsoft.NET\Framework64\v \InstallUtil.exe

      InstallUtil.exe 由 Microsoft 进行数字签名。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-02-20
        • 2010-09-20
        • 1970-01-01
        • 2011-12-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多