问题描述
我想知道开发 ASP.NET MVC 应用程序的最佳实践,可以选择在 Linux 上部署.如果您正在创建这些类型的 MVC 应用程序,
I'm wondering about best practices to develop ASP.NET MVC apps with an option to deploy on Linux. If you are creating these kinds of MVC apps,
- 您的目标是什么 Linux/Mono 平台?
- 您在 Windows 上做了多少开发,在 Linux 上做了多少?
- 您是否使用 ORM 来抽象数据库?哪一个?
- 您是否在 Linux 上运行构建引擎?测试呢?
- 您还使用了哪些其他工具?
- 除了 Windows 之外,针对 Linux 还做了多少额外的工作?
- 你遇到过哪些丑陋或惊喜?
推荐答案
我工作的公司将 Linux 上的 Mono 作为我们的主要部署环境.因此没有额外的"工作——我们提供整个堆栈,从硬件到操作系统(定制和修剪)再到应用程序.使用开源为我们和我们的客户节省了大量资金(是的,我们确实为我们所依赖的操作系统项目做出了贡献).
The company I work for targets Mono on Linux as our main deployment environment. Thus there is no "additional" work - we provide the whole stack, from hardware, through operating system (customized and trimmed) to applications. Using Open Source gives huge savings for us and our clients (and yes, we do contribute back to the OS Projects we rely on).
重要的是不断使用您的实际目标进行测试(抱歉,Windows 上的 Mono 不算在内).当然,开发人员使用 Visual Studio,但持续集成(使用 CruiseControl.Net,你需要 Mono 2.4.2 才能在 Linux 上运行它)在 Windows 和 Linux 上都完成了,测试了我们期望使用的所有 Mono 版本(它最近变得更加稳定,但仍然存在回归发生在版本之间).在一个 *nix 系统上运行 parallel Mono 版本 非常容易,你甚至可以包含一个 svn 快照构建,如果您更愿意尽早发现上游回归.如果您不推出自己的发行版,请记住大多数 Linux 供应商在发布 Mono 时都带有自定义补丁——这曾经给我们带来过问题.此外,许多发行版在更新 Mono 时有很多滞后,这是一个快速推进的项目.
The important thing is to constantly test using your actual target (sorry, Mono on Windows doesn't count). Sure, developers use Visual Studio, but the continous integration (using CruiseControl.Net, you'll need Mono 2.4.2 to run it on Linux) is done both on Windows and Linux, testing all Mono versions we expect to work on (it got much more stable recently, but still, regressions do happen between releases). It's quite easy to run parallel Mono versions on one *nix system, you can even include an svn snapshot build if you prefer to catch upstream regressions early. If you don't roll out your own distribution, then remember that most Linux vendors ship Mono with custom patches - this has caused problems for us before. Also, many distributions have a lot of lag updating Mono, and this is a rapidly advancing project.
对于数据库层,我们主要使用普通"ADO.NET - Oracle(使用 dotConnect for Oracle,它们支持 Mono)和 SQLite(Mono 附带一个工作连接器).我还使用了官方的 ADO.NET Driver for MySQL (Connector/NET) 和它,也,效果很好.ORM 映射比较棘手,但 NHibernate 是可用的(请记住,它们 不正式支持 Mono).
For database layer we use mostly "plain" ADO.NET - Oracle (with dotConnect for Oracle, they support Mono) and SQLite (Mono ships with a working connector). I have also used the official ADO.NET Driver for MySQL (Connector/NET) and it, too, works well. ORM mappings are more tricky, but NHibernate is usable (keep in mind that they do not support Mono officially).
至于构建引擎和测试 - NAnt 和 NUnit 是众所周知的并且经过充分测试.最新版本的 Mono xbuild(MSBuild 的克隆)实际上已经可用,但如果您决定将其用于更复杂的场景,请准备好贡献大量补丁.
As for the build engine and tests - NAnt and NUnit are well known and well tested. With most recent versions of Mono xbuild (clone of MSBuild) actually got usable, but prepare yourself for contributing quite a lot patches if you decide to use it for more complex scenarios.
编写测试.其中很多.准备好提供补丁和错误报告,如果您使用商业组件 - 请确保供应商正式支持 Mono.
Write tests. Lots of them. Be prepared to contribute patches and bugreports, and if you use commercial components - make sure the supplier officially supports Mono.
这篇关于在 Linux 上部署 ASP.NET MVC:最佳实践、工具和惊喜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!