.net Core Blimey - Smart Devs UG
-
Upload
citizenmatt -
Category
Technology
-
view
46 -
download
2
Transcript of .net Core Blimey - Smart Devs UG
![Page 1: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/1.jpg)
.NET CoreBlimey.
@citizenmatt
![Page 2: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/2.jpg)
This is Matt Ellis
He works for Microsoft, and is a developer on the .NET Core team.
This is not me.
![Page 3: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/3.jpg)
This is Matt Ellis
He works for JetBrains, and is an interested amateur in .NET Core.
This is me.
![Page 4: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/4.jpg)
What is .NET Core?
New .NET stack - CLR + BCL
Open SourceCross platform
(eventually)Standalone -
per-application installs
Factored for modularity - “cloud optimised”
Everything ships as NuGet packages,
including the runtime
Not finished…
![Page 5: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/5.jpg)
.NET Core != .NET Framework
NOT a new version of the .NET Framework
• .NET Framework is going nowhere
• .NET Core is 5.0.NET Framework is 4.6
• .NET Core is a fork of the .NET Framework Code merged back to TFS
• .NET Core is (currently) a strict subset of the .NET Framework
• Missing pieces in .NET CoreWindows: WinForms, WPF, COM, etc.Platform: AppDomains, Remoting, Reflection.Emit, etc.
• Different constraints:Ship cycles, compatibility, system wide install
![Page 6: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/6.jpg)
Why?
Multiple .NET stacks. Incompatibilities
Portable Class Librariesnot scalable
Cross platform
Independent release cyclesRuntime, BCL, apps
Nano Server
Tidy up15 years of evolution
![Page 7: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/7.jpg)
Why?
![Page 8: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/8.jpg)
Why?
Multiple .NET stacks. Incompatibilities
Portable Class Librariesnot scalable
Cross platform
Independent release cyclesRuntime, BCL, apps
Nano Server
Tidy up15 years of evolution
![Page 9: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/9.jpg)
History
Started with .NET Framework 2.0
![Page 10: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/10.jpg)
How do I get it?
NuGet
![Page 11: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/11.jpg)
How do I get it?
DNX - Dot Net Execution Environment
DNX maintained by asp.net team
Stable builds on nuget.orgUnstable on myget.org
.NET Core, .NET Fx and ASP.NET teams maintain own .NET Core builds…
dnvm install latest -r coreclr -u
![Page 12: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/12.jpg)
Build from source!
How do I get it?
![Page 13: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/13.jpg)
Architecture
Boxes and bits.
![Page 14: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/14.jpg)
.NET Native
Alternative runtime
• AOT compilation
• Compiles all dependencies Tree shaking
• Reflection? Via xml!
• Windows Store apps only
• Closed source
• LLILC - LLVM based JIT/AOT (OSS)
![Page 15: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/15.jpg)
CoreCLR The new runtime.
![Page 16: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/16.jpg)
dotnet/coreclr
JIT compiler (RyuJIT), Garbage Collector, Platform Abstraction Layer - C++
mscorlib (tightly coupled to runtime) - C#
PAL - OS and platform differences. E.g. exception handling, threads, etc.P/Invoke to OS, FEATURE #ifdefs
Book of the Runtime!
Mirror back to TFS
![Page 17: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/17.jpg)
CoreFX The new BCL.
![Page 18: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/18.jpg)
dotnet/corefx
Factored for modularity - each solution/assembly is a package
Some platform specific implementations, e.g. System.Console, Process.Interop.Unix.cs, etc.
Might throw PlatformNotSupportedException(e.g. Console.get_ForegroundColor )
Build is based on project.json, packages as references
Mirrored to TFS + .NET Framework
High compatibility bar for changes, transparent API review process
Console.get_ForegroundColorPlatformNotSupportedException
![Page 19: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/19.jpg)
AppModels
Or: How do you run a .exe on Unix?
![Page 20: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/20.jpg)
How the application is hosted and run
Environmental services
What is an AppModel?
Bootstrap the CLR Execute the application
![Page 21: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/21.jpg)
.NET Framework AppModels
.NET .exe
Originally a native stub that loaded the CLR (x86 only!)
Special cased by OS loader since Windows XP
Loads mscoree.dll, which initialises CLR and executes
app
IIS/asp.net
Pre-IIS 7 - ISAPI filter
IIS 7 directly integrates CLR
Pipes requests/responses to managed code
Lifetime management
Windows Phone / Windows Store
Magic!
“Application host” loads CLR
Integrates with environment events. E.g. suspend and
resume applications
Pre-compiled / .NET Native
![Page 22: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/22.jpg)
corerun
DNX - .NET Execution Environment (asp.net)
Windows 10 UWP Applications
.NET Core AppModels
coreconsole /osxcorebundlerun
![Page 23: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/23.jpg)
DNX
Dot NET Execution Environment
asp.net 5Targets .NET Core /.NET Framework /
Mono
In memory compilation via Roslyn
Changes project systemReference packages, not assemblies
More…
![Page 24: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/24.jpg)
• Packages for runtime and BCL
• BCL factored into many packages
• NuGet at heart of project system (DNX)
• NuGet is the new Portable Class Library
• Sketchy documentation…
NuGet v3
Bleeding edge.
![Page 25: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/25.jpg)
How does this affect us?
Let NuGet be NuGet
Don’t target a framework
Add NuGet dependencies for all BCL assemblies
Specify required versions of BCL assemblies
Let NuGet sort it out
Effectively, there is no longer a fixed framework
version to target
![Page 26: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/26.jpg)
New Target Framework Monikers
Brand new
• dotnet - - .NET Core contracts. “Replaces” portable- . Use this! Supports .Net Framework 4.5 and later (inc. Xamarin)
• dnx451 , dnx46 - DNX targeting .NET Framework 4.5.1, 4.6
• dnxcore50 - DNX targeting .NET Core
• uap10.0 - .NET Core 5.0 on Windows. AKA (UWP apps. Follows netcore45 / win8 , netcore451 / win81)
dotnet
dnx451 dnx46
dnxcore50
netcore50netcore45 win8 netcore451 win81
uap10.0
portable-*
![Page 27: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/27.jpg)
Resolution depends on project type
Project understands dotnet TFM: (UWP, .NET 4.6, ASP.NET 5)
“Modern PCL” with project.json: (What is a “Modern PCL”?)
More details on docs.nuget.org
dotnet
![Page 28: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/28.jpg)
What About Compatibility?
All .NET Core packages are PCLs. Kinda.
![Page 29: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/29.jpg)
PCL Refresher
1. A PCL is a class library that needs to run on multiple platforms and versions(e.g. .NET Framework, Windows Phone, Xamarin)
2. It defines a common subset of APIs that are available on ALL of the required versions of these platforms - a “Profile”
3. When targeting a Profile, the compiler references a set of Reference AssembliesThese describe the API with empty types, and forward types to correct assemblies
4. At runtime, the real assemblies on the target platform implement the APIs Can also forward types to other assemblies
![Page 30: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/30.jpg)
Portable Class Libraries
• PCL hides platform specific implementation details behind a common API contract
• Profiles do not scale. The more versions and platforms, the more Profiles…
![Page 31: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/31.jpg)
Why is this important?
Isn’t .NET Core a common, compatible, cross platform implementation?
• The BCL is the Base Class Library. It’s low level, and has to worry about underlying platform differences, e.g. file IO
• The BCL needs to be abstracted away from the platform, to allow for platform specific implementations. And refactoring!
![Page 32: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/32.jpg)
Reference Assemblies
BCL packages include a Reference Assembly in \ref
• This is referenced at compile time and provides the contract for the API, just like PCL Reference Assemblies
• The runtime implementation(e.g. \lib\netcore50 ) handles platform/host specifics
\ref
\lib\dnxcore50
![Page 33: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/33.jpg)
Why is this important?
This is how compatibility works
• Reference Assemblies allow consuming .NET Core packages from .NET Framework and other PCL platforms
• Reference Assembly provides the contract, forwards any types
• Implementation assemblies provide potential platform specific implementations
![Page 34: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/34.jpg)
Compatibility (not a guarantee)
• .NET Framework 4.5 can consume .NET Core packages
• .NET Core 5.0 is a subset of .NET Framework 4.6Should be able to consume .NET Framework 4.6 packages
• .NET Core can consume PCL libs that are compatible with System.Runtime.dll (facade that forwards to e.g. mscorlib.dll)
• A new PCL Profile will include .NET Core (e.g. )(Not announced as part of NuGet v3 - dotnet is checked before portable-* ?)
portable-dotnet+…+…
![Page 35: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/35.jpg)
Known Unknowns
• How are OS specific implementations going to be shipped? ( \runtimes ?)
• Do we need a Reference Assembly for each package?
• Why do we need platform/host TFMs (e.g. dnxcore50 ) when we can specify dependencies?
dnxcore50
\runtimes
http://docs.nuget.org/Create/uwp-create
![Page 36: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/36.jpg)
What does this mean for Mono?
Lots. Or not much.
Mono == .NET FrameworkMono already cross platform
Mono’s focus is non-Windows
mobile (Xamarin)
.NET Core’s focus is server and
Windows UWP
Mono can include CoreCLR + CoreFX
code
![Page 37: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/37.jpg)
Where does Roslyn fit in?
Orthogonal.
Runs on .NET Framework + Mono
Planned for.NET Core
CompilingCoreCLR + CoreFX
currently requires Windows
C# compilerwritten in C#
![Page 38: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/38.jpg)
.NET Core
Cross platform
Open Source
NuGet everywhere
Bleeding edge
Icons: http://icons8.com/
The future of .NET
![Page 39: .net Core Blimey - Smart Devs UG](https://reader034.fdocuments.in/reader034/viewer/2022052603/55d1e3a1bb61eb377b8b45db/html5/thumbnails/39.jpg)
Links
CoreCLR - https://www.github.com/dotnet/coreclr
CoreFX - https://www.github.com/dotnet/corefx
DNX - https://github.com/aspnet/Home
NuGet - http://docs.nuget.org
@citizenmatt