开发者

Introduce win service into setup

开发者 https://www.devze.com 2022-12-22 10:10 出处:网络
I开发者_如何学编程\'ve got win service, which I want introduce in all my products. So how can I add setup service to all my projects setups.

I开发者_如何学编程've got win service, which I want introduce in all my products. So how can I add setup service to all my projects setups. I try add service files to setup(exe,config ref dll) but it dosn't setup automatically and I should use installutil.exe. How can I install it with my products without usage installutil.exe. Can I use ServiceProcessInstaller and ServiceInstaller at setup project?

Thanks a lot


First read up about creating setups (yes, you can use ServiceProcessInstaller and ServiceInstaller in a setup)

Next, have a look at creating a merge module. A merge module is like a library that you can include into your setup. So you would create a merge module for your service, and you would include that merge module in each of your product setups.

Edit (added instructions for configuring merge module)

First, make sure that your service installs correctly if you use InstallUtil (that step verifies that your service installer and service process installer code is correctly written and attributed).

Next, once that'w working, I think that all you need to do is to configure your merge module to install the service. Here's how:

  • Open your solution and right-click on your merge-module project.

  • Select View | Custom Actions (a new tab will open in your text editor window)

  • In the Custom Actions editor tab, right-click on the Install folder and choose "Add Custom Action" ( a dialog opens)

  • In the Select Item in Project Dialog, drop down the "Look In" combo box and select "Module Retargetable Folder"

  • Click the "add output" button (another dialog)

  • In the Add Project Output Dialog, Select your service project in the Project dropdown.

  • In the Listbox, select "Primary Output" (you are telling the merge module to look for your installer code. You are saying look for it in the compiled output of my service project, and that at setup runtime that output will be in the service's install directory)

  • OK all of the dialogs.

  • Follow the same steps in the Uninstall folder so that your service will be uninstalled correctly as well.

Now, a small disclaimer: I know that this works with normal (msi) setup projects. I have not done it with a merge module, but I'm pretty sure that it will work.

Good Luck!


Begin at step 6 of the post here. Once you get to step 9, you'll be able to use InstallUtil.exe to install and uninstall your service.

Now, if you want to avoid having to use InstallUtil.exe, you can modify your service to install/uninstall itself from the command line. To do that, follow the steps that are discussed in this post.

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号