简体   繁体   English

C#如何为Windows服务创建安装项目以自动安装它?

[英]C# How to create a Setup project for a Windows Service to install it automagically?

I have seen multiple Windows Services getting installed in my computer with just an Setup.exe or .msi... is it something special that it needs to be done with the setup project to let such Windows Services installed in a easy way without Installutil.exe? 我已经看到多个Windows服务安装在我的计算机上只有一个Setup.exe或.msi ...这是一个特殊的东西需要用安装项目完成,以便在没有Installutil的情况下轻松安装这些Windows服务。可执行程序?

I have tried and it just doesn't install the Service. 我试过,它只是没有安装服务。 I know how to use Installutil but that I would think it's just for testing. 我知道如何使用Installutil,但我认为它只是用于测试。 I need to be able to install my windows service with an Setup.exe because I want to distribute my Service with its configuration Tray app. 我需要能够使用Setup.exe安装我的Windows服务,因为我想通过其配置托盘应用程序分发我的服务。

What would be the correct way to install the service and then my app? 安装服务然后我的应用程序的正确方法是什么? They both use a same DLL created in the same solution. 它们都使用在同一解决方案中创建的相同DLL。

Problem while Building a Setup Project for a windows Service? 为Windows服务构建安装项目时出现问题?

I looked at the link above but its about the Setup Project which I already know how to do, the problem is how to make my Setup project working... my DLL is getting up in place, the Tray app is working as well, the problem is the Service not getting installed it is just giving me the .exez 我看了上面的链接,但它关于我已经知道如何做的安装项目,问题是如何使我的安装项目工作...我的DLL正在起作用,托盘应用程序也正常工作,问题是服务没有安装它只是给我.exez

but I need it to be installed correctly like be up and running at reboot and in the Service Control Manager. 但我需要正确安装,例如在重启和运行控制管理器中启动和运行。

Option 1 选项1
1. Download Wix 1.下载Wix
2. Download and install Wix Windows Service Setup Project Template 2.下载并安装Wix Windows服务安装项目模板
3. Create a new wix setup project and see what you get 3.创建一个新的wix安装项目,看看你得到了什么

This is the easiest way to create a *.msi without any option windows 这是在没有任何选项窗口的情况下创建* .msi的最简单方法

Option 2 选项2
Follow this blog post . 关注此博文 Same as option 1 but without the project template. 与选项1相同但没有项目模板。 If you go the WiX route sooner or later you will see that the project template provides basic stuff. 如果你迟早去WiX路线,你会发现项目模板提供了基本的东西。 If you want more advanced stuff you need to learn WiX a little bit and use its candle.exe, light.exe, pyro.exe etc. 如果你想要更高级的东西,你需要学习一点点WiX并使用它的candle.exe,light.exe,pyro.exe等。

Option 3 选项3
I wrote a short post how I usually do this. 我写了一篇简短的帖子 ,我通常会这样做。

Good luck 祝好运

Here is a simple template for creating a *.msi installer for a Windows Service with WiX: 这是一个简单的模板,用于为使用WiX的Windows服务创建* .msi安装程序:

http://www.schiffhauer.com/wix-template-for-installing-a-windows-service/ http://www.schiffhauer.com/wix-template-for-installing-a-windows-service/

I was able to specify my DLL dependencies with File tags. 我能够使用File标签指定我的DLL依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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