在安装过程中使用InstallUtil.exe命令安装Windows服务

时间:2020-04-03 18:46:05

标签: c# installation installutil

我在Console Application中有一个Visual Studio Solution项目。此应用程序在这里被称为Semplicity MyApplication.exe,它不过是WCF服务的宿主。

我需要安装程序才能在目标计算机上安装我的应用程序,因此我下载了Microsoft Visual Studio Installer Projects扩展名。我收集了所有要复制到“应用程序文件夹”中的文件,但我希望安装程序甚至将我的服务注册为Windows服务。

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

enter image description here

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

enter image description here

以及以下Arguments:

“ [TARGETDIR] MyApplication.exe”

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

因此,在我的问题下方:

  • 我在哪里做错了什么?
  • 我可以检查任何日志吗?
  • 如果以前已经安装了该服务,我可以通过哪种方式卸载该服务?
  • 坦率地说,我期望可以进行更多的自定义。例如,与我的应用程序相关的其他复选框,或者用户可以在安装时进行管理的复选框。如果我的App.config包含KeyValue [Server =“ localhost”],则可以在安装时通过弹出窗口向用户自定义它:“您的服务器在哪里?”并根据提示信息更新我的配置文件由用户?

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

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

使用声明

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数字签名。

相关问题