简体   繁体   中英

Install a windows service with InstallUtil.exe command during an installation

I've a Console Application project in a Visual Studio Solution . This application, called here for semplicity MyApplication.exe, is nothing but an host of a WCF Service.

I need an installer for install my application on the target machine, so I download the Microsoft Visual Studio Installer Projects extension. I collected all the files I want to be copied into the Application Folder but I want that the installer even registers my service as a Windows Service.

For this goal, I imported the InstallUtil.exe just like shown on the below picture. I created the nested extra folders (Windows Folder -> Microsoft.NET -> Framework64 -> v4.030319) in order to reflect the actual structure of the target environment.

在此处输入图像描述

Then I created the Custom Action like this under the Commit node:

在此处输入图像描述

with the following Arguments:

"[TARGETDIR]MyApplication.exe"

I tried the generated setup and I noticed that all the files are copied but the service is not installed (I don't see it on the MSC list).

So, below my questions:

  • Where and what am I doing wrong?
  • Is there any log I can check?
  • In which way I can uninstall the service, if it was already installed previously?
  • Frankly speaking, I expected something more customizable.. For example additional checkbox related to my application or something that the user can manage at installation time. If my App.config contains a KeyValue [Server="localhost"] is there a way to customize it at installation time with a popup to the user: 'Where is your server?" and update my config file with the information prompted by the user?

Limits : Visual Studio Installer Projects have many limitations ( short version, Chris Painter ).

Alternative Tools : There are many other tools, some of which are free .


WiX Toolkit : The WiX Toolkit is free and open source. Here are two examples of how to install services without the need to run custom actions (the ability to install services is built-in to MSI, no need to use InstallUtil.exe - the "say no" to unnecessary custom action campaign ):


Links :

Perhaps this will be useful to someone in a similar situation.

Using Statement

using System.Configuration.Install;

Installing

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

Uninstalling

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

The above handles the functionality for the InstallUtil you've mentioned.

Documentation

ManagedInstallerClass.InstallHelper

Documentation on InstallUtil

The utility is located in the following places:

.NET directories on a Windows system:

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

InstallUtil.exe is digitally signed by Microsoft.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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