简体   繁体   English

在没有设置项目的情况下安装Windows服务

[英]Installing a windows service without a set up project

I have written a standard simple .net windows service in c#. 我已经用C#编写了一个标准的简单.net Windows服务。 Now I am looking to install it and running it. 现在,我正在寻找安装并运行它。

On MSDN, it says to add an installer to the project and create a setup project to deploy and install the service. 在MSDN上,它表示要在项目中添加安装程序并创建一个安装项目以部署和安装服务。 http://msdn.microsoft.com/en-us/library/aa984263%28v=vs.71%29.aspx http://msdn.microsoft.com/en-us/library/aa984263%28v=vs.71%29.aspx

I have added installers to my project. 我已将安装程序添加到我的项目中。 However I have Visual Studio 2012 which does not come with the setup project templates. 但是我有Visual Studio 2012,它没有安装项目模板。 What is the alternative to this? 有什么替代方法?

Also I know that the Visual Studio Command Prompt can call InstallUtil.exe which supposedly can install services. 我也知道Visual Studio命令提示符可以调用InstallUtil.exe,据说可以安装服务。 What is the difference between this and installing it with the set up project? 这与通过设置项目进行安装有什么区别? Would I still need installers in my project if I use InstallUtil.exe? 如果使用InstallUtil.exe,我的项目中仍需要安装程序吗?

You can use installutil.exe in an elevated command window for this, as you stated. 如您所述,可以在提升的命令窗口中使用installutil.exe

The Installer tool is a command-line utility that allows you to install and uninstall server resources by executing the installer components in specified assemblies. 安装程序工具是一个命令行实用程序,可让您通过执行指定程序集中的安装程序组件来安装和卸载服务器资源。 This tool works in conjunction with classes in the System.Configuration.Install namespace. 该工具与System.Configuration.Install命名空间中的类一起使用。

This is no different from using the installer, as far as getting the service setup. 就获得服务设置而言,这与使用安装程序没有什么不同。

The best free setup solution for VS devs is WiX right now. VS开发人员最好的免费设置解决方案是WiX The following thread explains how to install a service with it . 以下线程说明了如何使用它安装服务

If you don't like scripting you can try Advanced Installer , its GUI based, much easier to use and faster. 如果您不喜欢编写脚本,则可以尝试基于GUI的Advanced Installer ,它更易于使用且速度更快。 But you need a Professional edition, try it during trial, to install a service . 但是,您需要一个专业版,才能在试用版中尝试安装服务

I would really recommend that you check out TopShelf: https://github.com/phatboyg/Topshelf 我真的建议您查看TopShelf: https//github.com/phatboyg/Topshelf

You can develop your service as a console application and then deploy it as a service by running the .exe with -install on command line. 您可以将服务开发为控制台应用程序,然后通过在命令行上使用-install运行.exe来将其部署为服务。 No fuss with installer projects. 安装程序项目无需大惊小怪。

If you want to create simple installer then try NSIS (Nullsoft Installation System) - it has a lot of plug-ins ( http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin ) which can help you with registering/starting/stopping/... you service. 如果要创建简单的安装程序,请尝试使用NSIS(Nullsoft安装系统)-它有很多插件( http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin ),可以帮助您进行注册/启动/停止/。您服务。

If you want to create an Installer Project directly in Visual Studio you can use my tool (sorry for self promo) called Visual & Installer - download free Trial here: http://www.unsigned-softworks.sk/visual-installer/index.html 如果您想直接在Visual Studio中创建安装程序项目,则可以使用名为Visual&Installer的我的工具(对自己促销很抱歉)-在此处下载免费试用版: http : //www.unsigned-softworks.sk/visual-installer/index html的

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

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