views:

84

answers:

3

Hello everybody. 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

A: 

Google next time first please

TJMonk15
There are a lot of samples about deploying win service with ServiceProject. I need service setup without Service Project in my others products
Andrew Kalashnikov
+3  A: 

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.

Matt Davis
Matt Davis, thank you for the usefull answer.But is there any way install service automatically with my product without any additional actions (installutil.exe; run exe from cmd)
Andrew Kalashnikov
Please re-read the second link Matt references -- first comment states: "Note that this solution does not require the use of InstallUtil.exe, so you do not have to deliver it as part of your installation program."
Scott W
Scott, end of post states:"after you install your service on the target machine, just run your service from the command line (like any ordinary application) with the -install command line argument to install and start your service"
Andrew Kalashnikov
@Andrew Kalashnikov, simply copying your Windows service executable to the target machine won't work. *Something* has to register the executable with the system in order for it to run as a Windows service on that system. That is what `InstallUtil.exe` is used for. I simply don't like delivering it along with my application. That's why I've rigged my Windows service to register itself from the command line. My installation project (InstallShield) simply executes the command line feature during installation.
Matt Davis
Matt Davis, great. I don't use InstallShield. I use standard setup project. And I don't know how it can simply execute command line feature.
Andrew Kalashnikov
@Andrew Kalashnikov, I don't know how to do it with a deployment project. See if either of these two links help you: http://msdn.microsoft.com/en-us/library/zt39148a(VS.80).aspx or http://support.microsoft.com/kb/816169.
Matt Davis
Thank you. But it is standard samples, which I see everywhere. May be I want unreal think? And should a) power installation project b) copy and add to setup my project service to all product solutions?
Andrew Kalashnikov
+2  A: 

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!

JMarsch
JMarsch, thanks. I've created msm module with project output of my winService. Build it and include to my products setups. Run setup. All service content(service.exe,config,dll) in a right place. Good! But the service doesn't install, though I added to msm service project with ServiceInstallers.
Andrew Kalashnikov
@Andrew Kalashnikov: You need to tell the setup to look for custom code in your assembly. First, have you marked your installer with the installer attribute, and does it install correctly with InstallUtil? If so, then I think that all you need to do is set up your MSM project to use the custom action. I will edit my answer to describe how (not enough room in comments)
JMarsch
Andrew Kalashnikov
I'm glad it worked out for you! Regards.
JMarsch