从ASP.NET MVC 4.5的Web应用程序迁移到.NET的核心 [英] Migrate to .NET Core from an ASP.NET 4.5 MVC web app

查看:795
本文介绍了从ASP.NET MVC 4.5的Web应用程序迁移到.NET的核心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚被赋予的任务与一些技术我没那么熟悉 - 我们可爱的窗户ASP.NET MVC的Web应用程序应转换在Linux环境中使用

I've just been given an assignment with some tech I'm not that familiar with - our lovely windows ASP.NET MVC web app should be converted to be used in a linux environment.

我工作的健康,我们必须绝对不能丢失或首脑将推出(我们或他们)的用户数据。

I work in health and we have user data that absolutely cannot be lost or heads will roll (ours or theirs).

我通常不是C#/ ASP.NET的家伙 - 虽然我可以适应的任务。我一直在阅读过官方的文档@ HTTP:/ /docs.asp.net/en/latest/getting-started/installing-on-linux.html 并可以看到,这个任务实际上意味着'面向.NET CORE(或单)框架。

I'm typically not a C#/ASP.NET guy - though I can adapt for the task. I've been reading over the official docs @ http://docs.asp.net/en/latest/getting-started/installing-on-linux.html and can see that this task in effect means 'target the .NET CORE (or mono) framework'.

我GOOGLE了四周,有迁移似乎没有实际/简单的方法 - 只要学习新的模块化安装的的configs拍打到project.json和远离你去!之前,我尝试手动做到这一点 - 是否有任何信息你们可以告诉我吗?有些系统的流程可循?也许有些问题,我本应首先阅读?

I've googled around and there is no de facto / easy way of migrating it seems - just learn the new modular setup with the configs slapped into project.json and away you go! Before I try and do this manually - is there any info you guys could advise me on? Some systematic processes to follow? Perhaps some "gotchas" that I ought to have read beforehand?

该项目使用NHibernate和Autofac的DI - 似乎pretty的标准。我只是想知道有多少读/实验这将需要得到它在Linux服务器上运行 - 最终这是最重要

The project uses NHibernate and Autofac for DI - seems pretty standard. I just wanted to know how much reading/experimenting this would take to get it running on a linux server - ultimately that's what counts.

推荐答案

核心CLR和BCL还没有准备好进行生产。期。至少目前还没有,可能不适合半年到一年的时间。依赖的支持更是未知的,在这一点上。 Autofac没有核心CLR兼容库。他们会吗?这是什么地方开始研究。他们什么时候?这可能需要一段时间,这是一个项目的要求,即是你的控制范围之内。

The Core CLR, and BCL are not ready for production. Period. At least not yet and probably not for six months to a year. Dependency support is even more of an unknown at this point. Autofac has no core clr compatible library. Will they? That is somewhere to start researching. When will they? It could be a while and that is a project requirement that is outside your control.

即使对于非生产工作.NET的核心仍​​然是非常早。简单的答案是告诉你的老板等待6个月,怎么看都动摇了,而不是潜在的燃烧数百工时或pre-制作code。当然,这很可能是因此这里忽略的是,我怎么会今天继续进行,如果我绝对必须。

Even for non production work .NET core is still very early. The simple answer would be to tell your boss to wait six months and see how everything shakes out rather than potentially burn hundreds of man hours or pre-production code. Of course that is likely to be ignored so here is how I would proceed today if I absolutely had to.

有一些改动的合纵连横在你的问题。您正在寻找迁移从ASP.NET 4.5到ASP.NET 5.你也在寻找目标的新框架。最后你计划运行在一个新的环境的解决方案。所有这些都可以独立处理(虽然有些不是在人前),这样的路线我想借此。

There are a couple of changes rolled together in your question. You are looking to migrate from ASP.NET 4.5 to ASP.NET 5. You are also looking to target a new framework. Lastly you are planning on running the solution in a new environment. Each of these can be handled independently (although some not before others) so that is the route I would take.

第一阶段0)有没有DNX支持之前4.51的.NET Framework版本。您将部署DNVM选择DNX为目标。您无法定位有什么不适用,因此,如果您的项目目前正在针对前有所4.51更新程序,并确认不存在重大更改。

Phase 0) There are not DNX supporting versions of the .net framework prior to 4.51. You will deploy DNVM to select a DNX to target. You can't target what isn't available so if your project is currently targeting something prior to 4.51 update that and verify there are no breaking changes.

一期) DNVM和DNX是同时与现有的满.Net框架(4.51+)和.Net核心(5.0)兼容。这可能是很有诱惑力的直接跳到ASP.NET 5 .Net的核心5运行,但是这将是一个错误。由于.NET的核心需要根据DNX项目和DNX基于projectd还支持.NET 4.51的第一步是将切换到由asp.net 5引入的新项目结构它可能会需要一些经验和文件是斯巴达在这一点上。该目标将现有的应用程序(asp.net 4.5的.NET Framework 4.51运行DNX运行。没有项目迁移向导,所以你会从一个新的DNX项目(使用asp.net 5空模板开始)和复制在现有code,这看似微小的变化,但它打破了应用程序在Windows中安装框架唯一宿主的紧密耦合。一旦你有一个DNX环境中的codeBase的运行,你有奠定了基础为目标的其他环境。

Phase 1) DNVM and DNX are compatible with both the existing "full" .Net Framework (4.51+) and .Net Core (5.0). It may be tempting to jump right to ASP.NET 5 running on .Net Core 5 but that would be a mistake. Since .net core requires a dnx based project and dnx based projectd also support .net 4.51 the first step would be to switch to the new project structure introduced by asp.net 5. It will probably require some experimentation and documentation is spartan at this point. The target would be your existing application (asp.net 4.5 running on .net framework 4.51 running in dnx. There are no project migration wizards so you will be starting from a new dnx project (use asp.net 5 "empty" template) and copying in your existing code. This may seem a minor change but it breaks that tight coupling of the application to an installed framework on the windows only host. Once you have the codebase running in a dnx environment you have the groundwork laid to target other environments.

第2期)迁移到asp.net 5(MVC 6)。你仍然会瞄准全.NET Framework和Windows上运行。 .NET的核心不(而且永远不会)支持你的项目现有的asp.net版本(4.5)。然而asp.net 5是与两个完整的框架(4.x的)和芯(5)不兼容。这使您能够升级到asp.net 5而不改变了到.NET的核心能力。在第2阶段结束时的目标是使用asp.net 5对DNX .NET 4.x中运行Web应用程序(功能)。是仍然在Windows上,但我们正在接近跨平台的兼容性。

Phase 2) Migrate to asp.net 5 (MVC 6). You will still be targeting the "full" .net framework and running on windows. .Net core does not (and never will) support your project's existing asp.net version (4.5). However asp.net 5 is compatible with both the full framework (4.x) and core (5). This gives you the ability to upgrade to asp.net 5 without changing over to .net core. The target at the end of phase 2 is the web application (functional) using asp.net 5 running on .net 4.x in dnx. Yes still on windows but we are getting closer to cross platform compatibility.

第三期)拍摄中不支持在.NET核心现有BCL引用和依赖的库存清单。重构其不支持.NET的核心现有BCL引用。请记住.NET的核心是完整​​框架的一个子集,所以你可能会得到幸运,所有现有的code满足该子集,但如果你没有,你需要找到一种方法来实现相同的功能,在.NET中可用的子集核心。

Phase 3) Take inventory list of existing BCL references and dependencies which are not supported in .net core. Refactor existing BCL references which are not supported in .net core. Remember .net core is a subset of the full framework so you might get lucky and all existing code meets that subset but if you don't you need to find a way to achieve the same functionality with the subset available in .net core.

有关相关性(即Autofac),很可能你将需要升级,有可能被打破,需要加以解决的变化。目标和阶段3月底为第二阶段,但没有与该核心BCL不符的任何依赖Web应用程序。你的控制范围之内的最大因素是第三方软件包。如果autofac不释放核心CLR兼容包,那么你被卡住(或将需要考虑使用替代)。

For dependencies (i.e. Autofac) it is very likely you are going to need to upgrade and there may be breaking changes which need to be resolved. The target and the end of phase 3 is the web application from phase 2 but without any dependencies that are incompatible with the core bcl. The largest factor outside your control is third party packages. If autofac doesn't release a core clr compatible package then you are stuck (or will need to consider using an alternative).

第4期)第3阶段的结束意味着你有一个.NET的核心兼容的堆栈,但你仍然瞄准完整的框架。现在,最后你会切换目标,以核心CLR(dnvm支持多个并列运行时= DNX)。我仍然部署到窗户在这一点上,一次一个变量。在第4阶段结束时,您必须运行在托管在Windows环境.NET核心的Web应用程序。

Phase 4) The end of phase 3 means you have a .net core compliant stack but you are still targeting the full framework. Now finally you will switch the target to core clr (dnvm supports multiple side by side runtimes = dnx). I would still deploy to windows at this point, one variable at a time. At the end of Phase 4 you have the web application running on .net core hosted in windows environment.

第5期)。现在,您可以在解决任何Windows的依赖关系的工作。在迁移关闭IIS最小的样子,保证处理在OS中立的方式做任何路径,并且没有调用Windows特定的资源(如注册表)。核心CLR和bcl应该是比较成熟的由这点,所以你是不是要瞄准一个移动的目标。

Phase 5). Now you can work on resolving any Windows dependencies. At a minimum look to migrate off IIS, ensure any path handling is done in an OS neutral way, and there are no calls to windows specific resources (like registry). The core clr and bcl should be more mature by this point so you aren't trying to aim for a moving target.

试图做这一切一气呵成在我看来是一个灾难。有了这么多类似的变化,你就会开始一个非功能性的解决方案,可能仍然不起作用。通过把它分阶段,你可以在迁移对跨兼容的目标的解决方案,同时还具有输出功能在每一步。

Trying to do it all in one go is in my opinion a recipe for disaster. With so many parallel changes you will start with a non-functional solution and probably remain non-functional. By taking it in phases you can migration the solution towards a cross compatible target while still having functional output at each step.

这篇关于从ASP.NET MVC 4.5的Web应用程序迁移到.NET的核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆