简体   繁体   English

.NET有哪些常见的应用程序部署和配置最佳实践?

[英]What are common Application Deployment and Configuration Best Practices with .NET?

Here's my current scenario which is specifically what i'd like to discuss as a case study, however I want this to be open enough to address other deployment practices for .NET projects. 这是我当前的情况,这是我想作为案例研究具体讨论的内容,但是我希望它能足够开放以解决.NET项目的其他部署做法。

I have a .NET WPF Application written to perform manufacturing functional tests. 我编写了一个.NET WPF应用程序来执行制造功能测试。 Currently this software is deployed by copying the executable and it's dependancies to the target system. 当前,通过将可执行文件及其依赖项复制到目标系统来部署该软件。 The slave communications systems are installed similarly, but installutil needs to be used to register a WCF windows service. 从属通信系统的安装方式类似,但是需要使用installutil来注册WCF Windows服务。 This is all being done manually. 这些都是手动完成的。 Furthermore, configuration files are being read from custom xml data sources that are local to the application folder. 此外,将从应用程序文件夹本地的自定义xml数据源读取配置文件。 No app.config is being used. 没有使用app.config。

I think we can all agree this scenario is sub-par, and definately fails to even come close to an ideal launch condition 我认为我们都可以同意这种情况是低于标准的,绝对无法达到理想的发射条件

My questions are as follows: 我的问题如下:

  1. What should be used for setup and deployment? 设置和部署应使用什么? Setup and Deployment Wizard? 安装和部署向导? Click-Once Deployment? 点击一次部署?
  2. How should I go about automating the installation of the windows service? 我应该如何自动执行Windows服务的安装? Best way to specify custom username/password for the afforementioned service? 为上述服务指定自定义用户名/密码的最佳方法?
  3. What should be done about configuration if mutable application folder storage is considered harmful, how should I go about this? 如果可变的应用程序文件夹存储被认为是有害的,应该如何配置,我该如何处理? Isolated Application Storage? 隔离的应用程序存储?

Article links for any of the above would be ideal. 以上任何一个的文章链接都是理想的。

I can't really address all of you're questions, but to at least help with a portion of the problem I have experience with. 我无法真正解决您所有的问题,但至少可以帮助解决我所遇到的部分问题。

I found on a forum post, how to basically integrate InstallUtil into you're program, be basically doing what it does for you to install the service, since it's all built into .net. 我在一个论坛帖子中发现,如何将InstallUtil基本上集成到您的程序中,基本上是为您安装服务所做的事情,因为它全部内置于.net中。 So what the original forum poster did, and I've replicated myself into one of my base libraries, is basically if I want to create a service, I just create a console application that extends ServiceBase, override OnStart / OnStop and have all of my service code. 因此,最初的论坛发布者所做的事情,并且我已经将自己复制到我的一个基本库中,基本上就是如果我要创建服务,我只是创建一个扩展ServiceBase的控制台应用程序,覆盖OnStart / OnStop并拥有所有服务代码。 This is great because it allows me to debug right from Visual Studio, and then installing as a service just means running consoleapp.exe --install, and it'll run through everything that needs to be done to install the service. 这很棒,因为它允许我直接从Visual Studio进行调试,然后作为服务安装即意味着运行consoleapp.exe --install,它将贯穿安装该服务所需完成的所有工作。

However, for configuration and deployment itself, I'm still limited to doing a build, and just copying all the updated files to the server as required, and leaving that particular servers configuration file intact. 但是,对于配置和部署本身,我仍然仅限于进行构建,只是根据需要将所有更新的文件复制到服务器,并保留该特定服务器的配置文件不变。 I'm a large proponent of using version control for configuration files per server, and I'd really just write a script to copy the requires files between systems if you need to do it on alot of servers, but as stated I don't have alot of experience with this. 我大力支持使用版本控制来控制每台服务器的配置文件,如果您需要在很多服务器上使用它,我真的只是编写一个脚本在系统之间复制需求文件,但是正如我所说,有很多经验。 I hope integrating the service installer is helpfull though. 我希望集成服务安装程序对您有所帮助。

I believe this is the link to the original forum post for writing you're own installer 我相信这是原始论坛帖子的链接,用于编写您自己的安装程序

Since you mentioned WCF, though I would include this link about doing WCF from a Windows Service 既然您提到了WCF,尽管我会提供有关从Windows Service执行WCF的链接。

(1) What should be used for setup and deployment? (1) 应该使用什么进行设置和部署? Setup and Deployment Wizard? 安装和部署向导? Click-Once Deployment? 点击一次部署?

If you really want minimize risk of any deployment stuff ups due to human error, I'd be using WIX ( http://wix.sourceforge.net/ ) to create separate msi installers for both the client WFP application and the windows service. 如果您真的想最大程度地减少由于人为错误导致的任何部署负担的风险,那么我将使用WIXhttp://wix.sourceforge.net/ )为客户端WFP应用程序和Windows服务创建单独的msi安装程序。 WIX can be quite painful at times, but pretty much anything in terms of deployment can be achieved. WIX有时可能会很痛苦,但是就部署而言几乎可以实现。 There is a special WIX visual studio project available once WIX has been installed on your PC. 一旦在计算机上安装了WIX,就有一个特殊的WIX Visual Studio项目可用。

Enterprise IT guys I have worked with in the past have successfully used SMS or Active Directory to install any msi's I have created for them in the past using WIX rather than click-once. 我过去与之合作的企业IT人士已成功使用SMS或Active Directory使用WIX而非单击一次来安装我过去为他们创建的任何msi。 This really has nothing to do with WIX though. 不过,这确实与WIX无关。

(2) How should I go about automating the installation of the windows service? (2)我应该如何自动执行Windows服务的安装? Best way to specify custom username/password for the afforementioned service? 为上述服务指定自定义用户名/密码的最佳方法?

There are many articles on the web explaining how to install a windows service using WIX such as this one - Installing and starting a Windows Service using WiX . 网上有很多文章解释如何使用WIX安装Windows服务,例如本篇文章- 使用WiX安装和启动Windows服务 Using WIX you can set custom username/password parameters to be provided at install time. 使用WIX,您可以设置在安装时提供的自定义用户名/密码参数。 These parameters can be set via an MST file, or via the commandline using the msiexec.exe command. 这些参数可以通过MST文件设置,也可以使用msiexec.exe命令通过命令行设置。

(3) What should be done about configuration if mutable application folder storage is considered harmful, how should I go about this? (3)如果认为可变的应用程序文件夹存储有害,应该如何配置,我该如何处理? Isolated Application Storage? 隔离的应用程序存储?

Using WIX, mutable configuration files can become a thing of the past as xml config settings files for various environments including production can live in separate MST files controlled by system administrators only. 使用WIX,可变配置文件可以成为过去,因为用于各种环境(包括生产环境)的xml配置设置文件只能存在于由系统管理员控制的单独的MST文件中。 Added security for passwords and the like that live in secure key-safe repositories, these can be added via the commandline as described in the previous answer. 增强了密码安全性(位于安全密钥安全存储库中)的安全性,可以如上一个答案中所述通过命令行来添加。

The settings parameters are passed at install to time to generated various configuration files that can then be set a readonly or even encrypted - Using WiX to fix up XML files when deploying to different environments . 设置参数会在安装时传递给生成的各种配置文件,然后可以将其设置为只读甚至是加密- 在部署到不同环境时使用WiX修复XML文件

Yeah, 1, a Setup and Deployment project, easy peasy. 是的,1,一个安装和部署项目,简单易用。 How to configure the setup project to install the service with a custom action is described in detail in the "Creating a service application" walkthrough. “创建服务应用程序”演练中详细描述了如何配置安装程序项目以通过自定义操作安装服务。

My suggestion would be to use a Windows Installer project for the Service as it's really easy to configure default username and password. 我的建议是对服务使用Windows Installer项目,因为配置默认的用户名和密码确实很容易。 It's also easy to set the default state of the service (autostart, manual start, disabled,...). 设置服务的默认状态也很容易(自动启动,手动启动,禁用等)。

For the WPF app I'm actually using ClickOnce over Windows Shares. 对于WPF应用程序,我实际上是在Windows共享上使用ClickOnce。 It's easy to setup and it handles updates automatically. 它很容易设置,并且可以自动处理更新。

It would be great to use ClickOnce for the windows service part, but I had no success in doing it. 在Windows服务部分中使用ClickOnce会很棒,但是这样做没有成功。

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

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