net core blimey! (dotnetsheff jan 2016)
TRANSCRIPT
![Page 1: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/1.jpg)
.NET CoreBlimey.
@citizenmatt
![Page 2: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/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! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/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! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/4.jpg)
What is .NET Core?
New .NET stack - CLR + BCL
Open SourceCross platform
Standalone -per-application installs
Factored for modularity - “cloud optimised”
Everything ships as NuGet packages,
including the runtime
Not finished…RTM Q1 2016 (ish)
![Page 5: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/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 1.0.NET Framework is 4.6
• .NET Core is a fork of the .NET FrameworkCode 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! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/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! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/7.jpg)
Why?
![Page 8: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/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! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/9.jpg)
History
Started with .NET Framework 2.0
![Page 10: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/10.jpg)
How do I get it?
NuGet
![Page 11: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/11.jpg)
How do I get it?
.NET CLI tools (née DNX)
Official installer from dotnet.github.io
dotnet.exe, compilers (csc, vbc, fsc, ilc), NuGet,own .NET Core instance (runtime + fx)
dotnet.exe is a driver for other commandse.g. dotnet foo simply executes dotnet-foo
No more dnvm - runtime is genuine NuGet dependency now(“runtime.osx….” packages)
Global package cache
dotnet compile dotnet-compilednvm
runtime.osx.…
dotnet.exe
![Page 12: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/12.jpg)
How do I get it?
Build it from source!
![Page 13: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/13.jpg)
Architecture
Boxes and bits.
![Page 14: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/14.jpg)
CoreRT (née .NET Native)
Alternative runtime (optimisation)
• AOT compilation (RyuJIT → Native)
• Compiles all dependenciesTree shaking
• Reflection? Via xml!
• Open Source (dotnet/corert)
• Previously Windows Store onlyNow includes Mac + Linux (!)
• ILtoCPP - IL → C++ → nativeLLILC - LLVM based JIT/AOT
![Page 15: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/15.jpg)
CoreCLR The new runtime.
![Page 16: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/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! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/17.jpg)
CoreFX The new BCL.
![Page 18: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/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! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/19.jpg)
AppModels
Or: How do you run a .exe on Unix?
![Page 20: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/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! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/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! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/22.jpg)
corerun
.NET CLI
Windows 10 UWP Applications
.NET Core AppModels
coreconsole /osxcorebundlerun
![Page 23: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/23.jpg)
.NET CLI (née DNX)
Dot NET Execution Environment
started with ASP.NET Core
Targets .NET Core /.NET Framework /
Mono
Self contained .NET Core environment
Changes project system Reference packages, not assemblies
More…
![Page 24: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/24.jpg)
• Packages for runtime and BCL
• BCL factored into many packages
• NuGet at heart of project system (.xproj)
• NuGet is the new Portable Class Library
NuGet
Bleeding edge.
![Page 25: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/25.jpg)
How does it work?
.NET Core app.NET Core package
PCL package
.NET Framework package
.NET Framework app?
![Page 26: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/26.jpg)
Platforms
• No such thing as a .NET Core “app” App runs on a version of a platform, e.g. .NET CLI, .NET Framework, Windows UWP
• Platforms conform to a specific version of the .NET Standard Platform
• Packages target a real platform (e.g. lib/net46 ) or a specific version of the .NET Standard Platform - e.g. lib/netstandard1.3
• NuGet understands mappings between real platforms and n e tstandard versions (and PCLs)
• Can consume any compatible platform
• E.g. dnxcore50 maps to netstandard1. ; net46 to netstandard1.3 .NET CLI apps can consume net46 packages. But not vice versa (however, net461 can)
lib\net46lib\netstandard1.3
netstandardapp1.4 netstandard1.4 net46 netstandard1.3net46 net461
netstandard
![Page 27: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/27.jpg)
What is the .NET Standard Platform?
Replacing Portable Class Libraries
![Page 28: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/28.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 29: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/29.jpg)
Portable Class Libraries
• PCL hides platform specific implementation details behind a common API contract (reference assembly)
• Profiles do not scale. The more versions and platforms, the more Profiles…
• A published PCL lists all supported platformsIf a new platform is created, it isn’t supported
![Page 30: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/30.jpg)
Reference Assemblies in .NET Core
• Allows for different implementations on different platforms and operating systems, but common API
• Allows for refactoring the BCL!
• Reference Assemblies shipped in NuGet packages in \ref folder
• PCL consuming a package will use theReference Assembly at compile time, butimplementation assembly at runtime
\ref
![Page 31: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/31.jpg)
What is the .NET Standard Platform?
• A versioned collection of API contracts Reference assemblies
• Each version is a superset of the previous version - backwards compatible
• Similar to PCL Profile, but flipped Not list of supported platforms, but a single platform for other platforms to conform to
• Replaces PCLs with a single versioned moniker. Creating a new platform is easy
• Only works with .NET Framework ≧ 4.5!
![Page 32: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/32.jpg)
Huh?
Check out standard-platform.md in github.com/dotnet/corefx docs
![Page 33: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/33.jpg)
How does this affect us?
Creating NuGet packages
Target netstandardif possible
No implicit platform dependencies
Explicitly specify used dependencies
Version of dependencies is irrelevantImplied by .NET Standard Platform
Include PCL andreference assembly
if required
![Page 34: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/34.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 - - Application running on .NET CLI
• uap10.0 - .NET Core 5.0 on Windows. AKA (UWP apps. Follows netcore45 / win8 , netcore451 / win81)
netstandard1.X
netstandardapp1.X
netcore50netcore45 win8 netcore451 win81
uap10.0
portable-*
![Page 35: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/35.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 36: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/36.jpg)
Where does Roslyn fit in?
Orthogonal.
Runs on .NET Framework + Mono
Ships with .NET CLIrunning on .NET Core
Compiling CoreCLR + CoreFXcurrently requires Windows/Mono
C# compiler written in C#
![Page 37: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/37.jpg)
.NET Core
Cross platform
Open Source
NuGet everywhere
Bleeding edge
Icons: http://icons8.com/
The future of .NET
![Page 38: NET Core Blimey! (dotnetsheff Jan 2016)](https://reader034.vdocuments.net/reader034/viewer/2022052308/5889af561a28aba54d8b50f5/html5/thumbnails/38.jpg)
Links
CoreCLR - https://github.com/dotnet/coreclr
CoreFX - https://github.com/dotnet/corefx
CoreRT (.NET Native) - https://github.com/dotnet/corert
.NET CLI - https://github.com/dotnet/cli
NuGet - http://docs.nuget.org
@citizenmatt