部署ASP.NET MVC在Linux上:最佳实践,工具与; Suprises工具、NET、ASP、MVC

2023-09-02 21:55:39 作者:苏秋辰

我想了解一下最佳实践开发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 /单声道平台上,你定位? 您是如何发展做很多在Windows上,又有多少在Linux上? 您使用的ORM抽象的数据库?哪一个? 您是否运行在Linux上构建引擎?什么测试? 在其他什么工具,你用? 在多少额外的工作就一直以除目标Linux到Windows? 你有没有遇到过什么丑,愉快suprises?

推荐答案

我的目标,单在Linux上工作作为我们的主要部署环境的公司。因此,有没有额外的工作 - 我们提供的整个堆栈,从硬件,通过操作系统(定制和修剪)应用程序。使用开源提供更多折扣为我们和我们的客户(是的,我们也回馈给OS项目,我们依靠)。

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上不计数)。当然,开发人员使用Visual Studio,但连续集成(使用CruiseControl.Net,你需要单2.4.2在Linux上运行),在Windows和Linux上做两个,检验我们预计工作(它得到了稳定得多最近,不过,回归根本版本之间发生的)所有单声道版本。这是很容易跑并联单声道版本的在一个* nix的系统,你甚至可以包括SVN快照建立,如果你preFER以便及早发现上游的回归。如果不推出自己的分销,那么请记住,大多数Linux厂商出货单与自定义补丁 - 这已经引起了问题我们面前。此外,许多发行版有很多滞后的更新单,这是一个迅速发展的项目。

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 - 甲骨文公司(与的dotConnect为Oracle ,他们支持单声道)和SQLite(单声道附带一个工作连接器)。我也用的MySQL(连接器/ NET)官方 ADO.NET驱动程序,它也工作得很好。 ORM映射是更棘手,但NHibernate的是可用的(记住,他们的没有的支持单声道正式)。

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).

对于构建引擎和测试 - 楠和的 NUnit的的是公知的和很好的测试。随着最近的黑白xbuild(MSBuild的克隆)的版本实际上得到使用,但prepare自己的,如果你决定使用它进行更复杂的情况造成了很多的补丁。

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.

编写测试。很多人。要ppared贡献补丁和bug报告$ P $,如果你使用的商业组件 - 确保供应商正式支持单声道

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.