当前位置:网站首页>How to Net project migration to NET Core
How to Net project migration to NET Core
2022-06-23 20:49:00 【conanma】
quite a lot .net The project is under development ,.net core It hasn't appeared or matured yet , Now .netcore3.1 Already appeared , Its technical risk has been relatively low , Today, how to migrate the project to .net core Make a simple comb , Jin for reference .
Why from .NET Migrate to .NET Core?
.NET Core Features provided
1. The free and most liberal open source agreement
.NET Core be subordinate to .NET The foundation , Officially supported by Microsoft . Use the loosest MIT and Apache 2 Open source licenses , Document protocol compliance CC-BY. This will allow anyone and any organisation and business to do whatever they want , Including the use of , Copy , modify , Merge , publish , distribution , Re authorize , Or selling . The only limitation is , The above copyright and license tips must be included in the software , The latter agreement will provide users with a copyright license in addition , And patent licensing , And the license is free , nonexclusive ( Any individual or business can be empowered ) And it's permanent and irrevocable , The user to use .NET Core Don't worry about fees at all , You have the freedom to deploy anywhere .
2. Lightweight 、 Cross platform
3. Componentization 、 modularization 、IOC+Nuget、 middleware
4. High performance
5. Unified MVC and WebAPI Programming model
a) such as :ASP.NET Core in MVC and Web API Directly or indirectly inherit the same base class ControllerBase, Provide usable API It's also consistent
b) such as : used ASP.NET Time , Write the whole picture filter Need to aim at MVC and Web API Write code separately , But in ASP.NET Core, Use a set of middleware code directly
6. ...Testability
7. Microservices 、 Containerization support
8. Standardization .NET API standard - .NET STANDARD, The overall architecture is shown below :
.NET Core Performance improvement
1.TechEmpower Institutions
TechEmpower The agency will regularly talk to the mainstream web Performance testing of the framework
Address :https://www.techempower.com/benchmarks/
2. Blogger of blog Park 、 Microsoft MVP – Yang Xiaodong , It's done “Hello World” Performance testing
ASP.NET Core 1.1 Performance comparison evaluation (ASP.NET,Python,Java,NodeJS)
Address :https://www.cnblogs.com/savorboard/archive/2016/10/17/dotnet-benchmarks.html
Performance testing tools :
From Microsoft :Benchmarks
Address :https://github.com/aspnet/benchmarks
.NET How to move to .NET Core?
Migration workload assessment (API Compatibility Analysis )
Measure .net framework Migrate to .net core The amount of work
Address :https://www.cnblogs.com/vveiliang/p/7402409.html
Portability analysis tools :.NET Portability Analyzer
Address :https://github.com/Microsoft/dotnet-apiport
【Visual Studio Extension edition 】
Address :https://github.com/Microsoft/dotnet-apiport/tree/dev/docs/VSExtension
The evaluation will give a report similar to the following :
.NET Standard Versions
Address :https://github.com/dotnet/standard/blob/master/docs/versions.md
Migration plan development
Microsoft official 《 Organize projects to support .NET Framework and .NET Core》 In the article , There are two migration options :
Scheme 1 、 Put the existing project and .NET Core The project is combined into a single project ( A multi-objective framework )
Option two 、 Put the existing project and the new .NET Core Project separation ( Copy to new project )
By class name 、 Namespace , Inquire about API Implementation information of
During migration , There is a class library namespace being adjusted ,nuget The attribution package is adjusted , The specific class library is .NET Core Which version is implemented is not very clear , Through the following two query assistant , You can solve these problems .
1、 Query namespace 、 Where is the class library nuget package The package defines ( The first query is slow )
Address :https://packagesearch.azurewebsites.net/
2、 Inquire about NET API Implemented in various versions
Address :https://apisof.net/catalog/
The results are as follows :
The class library project 、 How to choose framework type for application project
1. How to organize a multi-objective framework at the same time C# Project solutions
Address :https://walterlv.com/post/organize-csharp-project-targeting-multiple-platforms.html
2..NetStandard;.netCore;FX(.NetFrameWork) Quoting relationship between
stay .NET Standard 2.0 in , We put in .NET Standard The library references the existing through a compatibility layer .NET Framework It's possible . Of course , This only applies to those who only use .NET Standard API Of .NET Framework The library works .
FX quote .NetCore: Not through
.NetStandard quote .NetCore: Not through
.NetCore quote FX: adopt
.NetCore quote .NetStandard: adopt
.NetStandard quote FX: adopt
FX quote .NetStandard: adopt
ASP.NET Core Can be in “.NET Framework and .NET Core” Up operation , but ASP.NET Core 3.0 And later only in .NET Core Run in .
Specific see :
【 translate 】 Introduce .NET Standard
Address :https://www.cnblogs.com/jinanxiaolaohu/p/10681024.html
About .net core and .net fx The question of cross reference
Address :https://q.cnblogs.com/q/103398/
.NetStandard;.netCore;FX(.NetFrameWork) Quoting relationship between
Address :https://www.cnblogs.com/xiaoliangge/p/7475268.html
3. The project supports a multi-objective framework
Support multi-objective framework , And solve the problem of third-party library reference differences ( stay csproj Include conditions... Are specified in the file )
Address :https://walterlv.com/post/configure-projects-to-target-multiple-platforms.html
Target frame name list ( Name all lowercase )
Address :https://docs.microsoft.com/zh-cn/nuget/reference/target-frameworks
How to debug a multi-objective framework class library ?
Address :https://docs.microsoft.com/zh-cn/nuget/reference/target-frameworks
NET Standard/Core Project use condition judgment output multiple versions xml Annotation document
Address :https://blog.csdn.net/starfd/article/details/78839704
4. Sharing code scheme in multi-objective framework
1、【 The preferred 】.NET Standard, Need goals SDK Support the corresponding .NET Standard edition .
2、 Sharing Project . Shared the source code directly , As long as the conditional compiler is specified in the target project , Then the source code can be compiled for different target frameworks .
3、[add as link] Use link sharing Visual Studio Code file in
Address :https://blog.csdn.net/starfd/article/details/78839704
5. Conditional compilation symbols ( Name all uppercase )
Instructions :#if #elif #else #endif (||、&&、!)
Because the goal framework provides API inequality . So conditional compilation symbols can be added if necessary to support different runtime versions .
Microsoft has predefined preprocessor symbols for each target framework ,vs These framework conditional compilation symbols are automatically recognized at compile time .
.NET Framework 4.5 --> NET45
.NET Framework 4.6 --> NET46
.NET Framework 4.6.1 --> NET461
.NET Standard 1.0 --> NETSTANDARD1_0
.NET Standard 1.6 --> NETSTANDARD1_6
.NETCOREAPP 2.0 --> NETCOREAPP2_0
Reference resources :
#if Instruction documents
Address :https://blog.csdn.net/starfd/article/details/78839704
How to compile conditional symbols (DefineConstants) Pass to msbuild
Address :http://www.voidcn.com/article/p-nsrcccet-btr.html
Migrate to .NET Core, But it only runs in windows On the platform
Use Windows Compatibility pack migrates code to .NET Core
Address :https://docs.microsoft.com/zh-cn/dotnet/core/porting/windows-compat-pack
how : take Windows Form desktop application porting to .NET Core
Address :https://docs.microsoft.com/zh-cn/dotnet/core/porting/winforms
how : take WPF Desktop applications are ported to .NET Core
Address :https://docs.microsoft.com/zh-cn/dotnet/core/porting/wpf
compatible .NET Core or .NET Standard API
transfer HttpHandler And HttpModule To ASP.NET Core middleware
Address :https://docs.microsoft.com/en-us/aspnet/core/migration/http-modules?view=aspnetcore-2.2
.NET CORE 2.0 Step on the pit and record ConfigurationManager
Address :https://www.cnblogs.com/binbinxu/p/7440342.html
.NET Core/Standard 2.0 Compile times “CS0579: Duplicate 'AssemblyFileVersionAttribute' attribute” error
1. Automatic generation AssemblyInfo Principle
Address :https://www.cnblogs.com/binbinxu/p/7440342.html
2. Solution : Don't automatically create AssemblyInfo file
Address :https://cloud.tencent.com/developer/article/1402303
ASP.NET Core Development of HttpContext
Address :https://www.cnblogs.com/linezero/p/6801602.html
.net core Use JsonConvert replace JavaScriptSerializer
Address :https://my.oschina.net/idoop/blog/915555
ASP.NET Core Read repeatedly in Request.Body The right posture
Address :http://www.cnblogs.com/dudu/p/9190747.html
JsonRequestBehavior stay core Problems removed in
1.[ASP.NET MVC] solve " If you want to allow GET request , Please put JsonRequestBehavior Set to AllowGet"
Address :https://shiyousan.com/post/635428880708292949
2.[ASP.NET Core]core Don't throw AllowGet abnormal , about DenyGet Then use [HttpPost] Instead of
Address :https://stackoverflow.com/questions/38578463/asp-net-core-the-name-jsonrequestbehavior-does-not-exist-in-the-current-cont
https://stackoverflow.com/questions/8464677/why-is-jsonrequestbehavior-needed?r=SearchResults
obtain ASP.NET Core Medium Web Root path and content root path ( Removed MapPath)
Address :http://beidouxun.com/Articles/Details/419f4786-679c-4316-b2bb-baea26c94205
Why is my conversation state in ASP.NET Core I don't work anymore ?
Address :https://www.cnblogs.com/lwqlun/p/10526380.html
because ASP.NET Core 2.1 Introduced in Cookie Consent and non necessity cookie Of GDPR Function causes .(GDPR, namely General Data Protection Regulation,《 General data protection regulations 》)
stay ASP.NET4.5 and ASP.NET Core Share cookies Authentication information ( The encryption and decryption methods are inconsistent )
.NET Cross platform travel :ASP.NET Core From tradition ASP.NET Of Cookie Read user login information in
Address :https://www.cnblogs.com/cmt/p/5940796.html
Open source solutions :[git]idunno.CookieSharing
Address :https://github.com/blowdart/idunno.CookieSharing
ASP.NET Core How to get the client IP Address ( Removed ServerVariables object )
Address :https://www.cnblogs.com/dudu/p/5972649.html
How to get all assemblies that a project depends on
Scheme 1 :AppDomain.CurrentDomain.GetAssemblies(), This method cannot get all dependent assemblies , because .Net There is a mechanism to delay loading assemblies
Option two : Apply to traditional ASP.NET project ,System.Web.Compilation.BuildManager.GetReferencedAssemblies();
Option three : Apply to ASP.NET Core project ,DependencyContext.Default.CompileLibraries, Refer to the following for specific codes
Reference resources :
AppDomain.CurrentDomain.GetAssemblies()
Address :https://www.cnblogs.com/beixing/p/3803874.html
Is there an alternative for BuildManager.GetReferencedAssemblies() in ASP.NET Core?
Address :https://stackoverflow.com/questions/53989393/is-there-an-alternative-for-buildmanager-getreferencedassemblies-in-asp-net-co
.NET Core 2.0 transfer System.Runtime.Caching
Address :https://www.cnblogs.com/mantgh/p/7429551.html
.NET Core 2.0 Upgrade to 3.0 Practical plan
Address :https://www.cnblogs.com/laozhang-is-phi/p/11520048.html
from .NET CORE2.2 Upgrade to 3.0 Process and some problems encountered
Address :https://www.cnblogs.com/roadflow/p/11711686.html
transfer EF frame
【 Microsoft official 】 from EF6 To EF Core The migration series
Address :https://www.cnblogs.com/roadflow/p/11711686.html
【 Microsoft official 】EF Core Version upgrade migration series
Address :https://docs.microsoft.com/zh-cn/ef/core/what-is-new/ef-core-2.2
It is amended as follows ASP.NET Core Application of style
Modify... As above API After compatibility , The framework class library can be successfully migrated to .NET Core, Compile and pass , The code is running normally . however ASP.NET Core Application of style , There are many changes in its writing . Please refer to the following documents for details :
Will tradition ASP.NET Application migration to .NET Core
Address :https://mp.weixin.qq.com/s?__biz=MzAwNTMxMzg1MA==&mid=2654072516&idx=3&sn=af3916ec4e2c31c231f5f01be75712d8&chksm=80dbca91b7ac43870a3fa4dce10f5a97adf1548d1381a99f27972c67c00a1e593aa926b110ad&mpshare=1&scene=23&srcid=0311kxbJ5rwkIYu7xO2Yx08U
【 Microsoft official 】ASP.NET Migrate to ASP.NET Core Tutorial series
Address :https://docs.microsoft.com/zh-cn/aspnet/core/migration/proper-to-2x/?view=aspnetcore-2.2
【 Microsoft official 】ASP.NET Core Version upgrade migration series
Address :https://docs.microsoft.com/zh-cn/aspnet/core/migration/20_21?view=aspnetcore-2.2
Related articles :
.NET Core 3 Performance improvements in ( translation )
Address :https://zhuanlan.zhihu.com/p/66152703
Java(11,12) And .NET Core(2.2,3.0) Performance comparison test
Address :https://blog.csdn.net/hez2010/article/details/86551299
边栏推荐
- Implementation of flashback query for PostgreSQL database compatible with Oracle Database
- Advantages of short video automatic audit? What are the difficulties of manual audit?
- How to build Tencent cloud game server? Differences between cloud game platforms and ordinary games
- [vernacular technology] QR code
- 35 year old crisis? It has become a synonym for programmers
- [golang] quick review guide quickreview (VIII) -- goroutine
- 国元期货交易软件正规吗?如何安全下载?
- [golang] some questions to strengthen slice
- What is the role of short video AI intelligent audit? Why do I need intelligent auditing?
- How do I close and restore ports 135, 139 and 445?
猜你喜欢

SQL聯合查詢(內聯、左聯、右聯、全聯)的語法

Ugeek's theory 𞓜 application and design of observable hyperfusion storage system

The "open source star picking program" container pulls private images from harbor, which is a necessary skill for cloud native advanced technology

Technology sharing | wvp+zlmediakit realizes streaming playback of camera gb28181

重庆 奉节耀奎塔,建成后当地连中五名进士,是川江航运的安全塔

Eight misunderstandings, broken one by one (final): the cloud is difficult to expand, the customization is poor, and the administrator will lose control?

Rstudio 1.4 software installation package and installation tutorial

ZABBIX monitoring - Aruba AP operation data

Yaokui tower in Fengjie, Chongqing, after its completion, will be the safety tower for Sichuan river shipping with five local scholars in the company

UGeek大咖说 | 可观测之超融合存储系统的应用与设计
随机推荐
Postman tutorial - teach you API interface testing by hand
Do you need a server to set up cloud on demand? What services can cloud on demand provide?
[hot sales at the beginning of the year] | the first special offer of popular cloud products is second to none, and the first year of 1-core 2G cloud server is 38 yuan!
【Golang】快速复习指南QuickReview(一)——字符串string
Development and code analysis of easycvr national standard user defined streaming address function
[vernacular technology] QR code
JS chain call
测试的重要性及目的
Eight misunderstandings, broken one by one (final): the cloud is difficult to expand, the customization is poor, and the administrator will lose control?
券商选哪个比较好尼?本人小白不懂,在线开户安全么?
Is Guoyuan futures trading software formal? How to download safely?
教你如何用网页开发桌面应用
How to make a commodity price tag
Bypass memory integrity check
小程序开发框架推荐
How does the fortress machine connect to the server? Novice must know operation steps
【Golang】类型转换归纳总结
Can Tencent cloud disk service share data? What are the advantages of cloud disk service?
徽商期货交易软件正规吗?如何安全下载?
Syntax of SQL union query (inline, left, right, and full)