vb.net Windows 服务 - 创建安装程序 Visual Studio 2012 如何?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12595967/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 16:18:28  来源:igfitidea点击:

Windows Service - Creating an installer Visual studio 2012 How?

vb.netwindows-servicesinstallervisual-studio-2012

提问by MMM

I'm developing a Windows service in VS2012 and the setup/deployment part has been removed. So I'm not able to create a setup project. I would like to hear what you guys could recommend for a good easy to use the installer. I need to take some inputs, only strings, under the installation of the service. I've been looking at WiX but that seems a bit complex, and I only got 1 or 2 days to make this installer.

我正在 VS2012 中开发 Windows 服务,并且安装/部署部分已被删除。所以我无法创建安装项目。我想听听你们对易于使用的安装程序有什么建议。我需要在服务的安装下进行一些输入,只有字符串。我一直在研究 WiX,但这似乎有点复杂,而且我只有 1 或 2 天的时间来制作此安装程序。

So what installer should I use other than Wix?

那么除了Wix之外我应该使用什么安装程序?

回答by TarkaDaal

I've had really bad experiences with InstallShield LE (the one that comes with Visual Studio 2012), especially for Windows Services. The features that you need to install a service (custom actions, etc), don't come with the light version.

我在 InstallShield LE(Visual Studio 2012 附带的那个)方面有过非常糟糕的经历,尤其是对于 Windows 服务。安装服务所需的功能(自定义操作等),不包含在轻量版本中。

What I'm planning to do for the current Windows service I'm working on is to build it with Topshelf, which (amongst other things) means installing your service is as simple as running MyServiceApp.exe install. I'm sure even InstallShield will let you run your app once it's installed, and then your app/Topshelf can install the service component.

我计划为我正在处理的当前 Windows 服务做的是用Topshelf构建它,这(除其他外)意味着安装服务就像运行MyServiceApp.exe install. 我敢肯定,即使 InstallShield 安装后也会让您运行您的应用程序,然后您的应用程序/Topshelf 可以安装服务组件。

If InstallShield doesn't work for you, I've had good results before with NSIS. Simple, powerful, free, decent documentation. It looks a bit clunky.

如果 InstallShield 对您不起作用,我之前使用NSIS取得了不错的结果。简单、强大、免费、体面的文档。它看起来有点笨重。

回答by Cosmin Pirvu

Here is a list of setup tools which can get you started: http://en.wikipedia.org/wiki/List_of_installation_software

以下是可以帮助您入门的安装工具列表:http: //en.wikipedia.org/wiki/List_of_installation_software

If you don't have a lot of time for creating the installer, I recommend using a commercial tool like Advanced Installer or InstallShield. You need a license, but they are focused on usability (do more in less time).

如果您没有很多时间来创建安装程序,我建议您使用像 Advanced Installer 或 InstallShield 这样的商业工具。您需要许可证,但他们专注于可用性(用更少的时间做更多的事情)。

回答by Paul Pavlinovich

You can do it with InstallShield LE... You can add custom actions "After Register Product" for install and for "After System Changes". These custom actions can run an EXE on the machine.

您可以使用 InstallShield LE... 您可以为安装和“系统更改后”添加自定义操作“注册产品后”。这些自定义操作可以在机器上运行 EXE。

Make sure you run the command line tools "in system context"

确保在“系统上下文”中运行命令行工具

After Register Product run the version of InstallUtil to your version of .NET eg. path=C:\Windows\Microsoft.NET\Framework\v4.0.30319 command=InstallUtil.exe "C:\Program Files (x86)\XXX\YYY\ZZZ.exe" replacing XXX YYY and ZZZ to match your install

在注册产品后,将 InstallUtil 版本运行到您的 .NET 版本,例如。path=C:\Windows\Microsoft.NET\Framework\v4.0.30319 command=InstallUtil.exe "C:\Program Files (x86)\XXX\YYY\ZZZ.exe" 替换 XXX YYY 和 ZZZ 以匹配您的安装

After System Changes to delete your service name run e.g. sc delete "servicename"

在系统更改以删除您的服务名称后运行例如 sc delete "servicename"

Note you need support for the custom actions within your own service executable (you needed this in earlier VS too).

请注意,您需要支持您自己的服务可执行文件中的自定义操作(您在早期的 VS 中也需要它)。

You can find more information about SC here: http://support.microsoft.com/kb/251192

您可以在此处找到有关 SC 的更多信息:http: //support.microsoft.com/kb/251192

回答by Tone

To add an installer for a service, you just need to right-click on the designer for the service and click "Add Installer".

要为服务添加安装程序,您只需右键单击该服务的设计器,然后单击“添加安装程序”。

Here's the walkthrough: http://msdn.microsoft.com/en-us/library/zt39148a.aspx

这是演练:http: //msdn.microsoft.com/en-us/library/zt39148a.aspx