net core
TRANSCRIPT
.NET CoreHow to migrate and write new code for .NET Core
Bertrand Le Roy
▪ Senior Program Manager on .NET Core
▪ One of the founders of Orchard
▪ http://weblogs.asp.net/bleroy
▪ https://blogs.msdn.microsoft.com/dotnet/tag/week-in-net/
▪ https://www.youtube.com/channel/UCvtT19MZW8dq5Wwfu6B0oxw
Objectives
▪ What’s .NET Core and when to use it (or not)
▪ How to create a new library, ASP.NET, or console application
▪ How to port existing code
Innovation
Any platformOpenness
.NET CoreASP.NET 5
.NET Core ≠ .NET Framework
.NET Framework 4.6
▪ .NET implementation for any scenario on Windows with comprehensive library support
.NET Core
▪ Modular and smaller implementation of .NET
▪ Cross-platform▪ App-level isolation▪ Built in the open▪ Optimized for specific workloads▪ Built for the next ten years of software development
WPF Windows Forms
Universal Windows Apps
ASP.NET (4.X) ASP.NET Core
Next gen JIT (RyuJIT)SIMD
Runtime Components Compilers
Languages innovation.NET Compiler Platform
.NET Core 5 Libraries
.NET Framework 4.6 Libraries
NuGet packagesCommon
.NET Framework 4.6 .NET Core
What’s common, and what’s not?
What’s not supported?
▪ WPF
▪ Winforms
▪ WebForms
▪ Binary serialization…
▪ Anything Windows-specific: registry, ACLs, perf counters, etc.
Significant change: Reflection
foo.GetType() → foo.GetType().GetTypeInfo()
If you can’t find it on Type, try TypeInfo
Extension method from System.Reflection
API Portability resources
▪ Portability analyzer VS extension▪ https://github.com/Microsoft/dotnet-apiport/releases▪ http://dotnetstatus.azurewebsites.net/ ▪ https://packagesearch.azurewebsites.net/ ▪ http://forums.dotnetfoundation.org/ ▪ https://gitter.im/dotnet/corefx ▪ https://dotnet.github.io/porting *
* soon
Managing expectations
▪ This is very much a new platform with a known flavor
▪ There is a cost to migration
▪ There are things to learn
▪ Not all projects can or should migrate
Should I migrate my project?
Cannot:
▪ WPF, WinForms, unless UWP
▪ ASP.NET WebForms
Should (absolutely):
▪ General purpose libraries
Should (maybe):
▪ ASP.NET MVC
▪ Micro-services
▪ Console apps
▪ Rewrite
▪ Talent expertise on Linux
DEMOPorting FluentPath
Dependencies
▪ Most fundamental libraries first: test frameworks, tooling, data access, JSON, logging, IoC, etc.
▪ Go to the source, ask the author
▪ Offer to help, or fork
▪ Switch to another Core-compatible library
▪ DIY
Testing
▪ xUnit was first, now NUnit, MsTest
▪ Secondary test libraries (mocking, functional testing, etc.) in progress
Debugging
▪ On Windows: Visual Studio
▪ Everywhere: VS Code
Tooling
Your choice of tool, on your choice platform
▪ Visual Studio on Windows
▪ Visual Studio Code on Mac, Linux, or Windows
▪ vi or emacs with OmniSharp
▪ etc.
.NET CLI replaces DNX, DNVM, DNU
▪ dotnet new
▪ dotnet restore
▪ dotnet run
▪ dotnet build
▪ dotnet build –native
▪ dotnet dosomethingcool
Scaffolds a minimal app
Restores packages for the project
Compiles and runs the app
Compiles to IL
Compiles to a single executable
You can build your own commands
DEMOCreating a new application
Q&A