Home » Useful Services » Windows service c# writing service installer

Windows service c# writing service installer

Windows service c# writing service installer you would use

In the service project do the following:

  1. In the solution explorer double click your services .cs file. It should bring up a screen that is all gray and talks about dragging stuff from the toolbox.
  2. Then right click on the gray area and select add installer. This will add an installer project file to your project.
  3. Then you will have 2 components on the design view of the ProjectInstaller.cs (serviceProcessInstaller1 and serviceInstaller1). You should then setup the properties as you need such as service name and user that it should run as.

Now you need to make a setup project. The best thing to do is use the setup wizard.

Right click on your solution and add a new project: Add > New Project > Setup and Deployment Projects > Setup Wizard

a. This could vary slightly for different versions of Visual Studio. b. Visual Studio 2010 it is located in: Install Templates > Other Project Types > Setup and Deployment > Visual Studio Installer

On the second step select “Create a Setup for a Windows Application.”

  • On the 3rd step, select “Primary output from. “
  • Click through to Finish.
  • Next edit your installer to make sure the correct output is included.

    1. Right click on the setup project in your Solution Explorer.
    2. Select View > Custom Actions. (In VS2008 it might be View > Editor > Custom Actions)
    3. Right-click on the Install action in the Custom Actions tree and select ‘Add Custom Action. ‘
    4. In the “Select Item in Project” dialog, select Application Folder and click OK.
    5. Click OK to select “Primary output from. ” option. A new node should be created.
    6. Repeat steps 4 – 5 for commit, rollback and uninstall actions.

    You can edit the installer output name by right clicking the Installer project in your solution and select Properties.

    Windows service c# writing service installer name and user that

    Change the ‘Output file name:’ to whatever you want. By selecting the installer project as well and looking at the properties windows, you can edit the Product Name. Title. Manufacturer. etc.

    Next build your installer and it will produce an MSI and a setup.exe. Choose whichever you want to use to deploy your service.

    @Christopher Painter I have been using the MS installer since2k5 and it has never had a problem. Whether or not you agree with it and consider it an ’;anti-pattern’; is not the point of this question, it is how do I do x with y, not how do I do a with b. When I posted the question it was for documentation purposes. Kelsey Jan 27 ’12 at 15:06

    @BrendanLeber I don’;t think you need to do all that. Just select ServiceInstaller1 on the ProjectInstaller.cs design surface in your service project and then look at the properties window. Set the StartType property to Automatic and it will startup as soon as it is installed. I don’;t think you need all that code or complexity. Kelsey Jan 26 ’12 at 17:14

    @Christopher – I don’;t. My solution isn’;t a replacement for a full installer that you would use to distributing software. I am presenting another option that works for some situations, such as mine where I write software that drives embedded PCs in unattended kiosks. Brendan Leber Jan 27 ’12 at 17:12

    InstallUtil classes ( ServiceInstaller ) are considered an anti-pattern by the Windows Installer community. It’s a fragile, out of process, reinventing of the wheel that ignores the fact that Windows Installer has built-in support for Services.

    Windows service c# writing service installer slightly for different

    Visual Studio deployment projects ( also not highly regarded and deprecated in the next release of Visual Studio ) do not have native support for services. But they can consume merge modules. So I would take a look at this blog article to understand how to create a merge module using Windows Installer XML that can express the service and then consume that merge module in your VDPROJ solution.

    answered Jan 26 ’12 at 19:54

    Your Answer

    2016 Stack Exchange, Inc


    Share this:
    custom writing low cost
    Order custom writing

    ads