How to install a Windows service developed in .NET 3.5?

前端 未结 4 1772
不知归路
不知归路 2021-02-04 15:12

I have developed a Windows service using Visual Studio 2008. I want to install that service in a machine where Visual Studio is not installed, but .NET 3.5 is installed.

4条回答
  •  孤独总比滥情好
    2021-02-04 15:35

    It's actually really simple as I just did it a couple of days ago for something I made.

    So in your service project you want to:

    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.

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

    1. Right click on your solution and add a new project: Add > New Project > Setup and Deployment Projects > Setup Wizard
    2. On the second step select "Create a Setup for a Windows Application."
    3. On the 3rd step, select "Primary output from..."
    4. Click through to Finish.

    Now you need to 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 > 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.

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

提交回复
热议问题