.NET Core is a new framework inside .NET Ecosystem. It helps developers to the new challenges of a Cloud First World, and it is not a replacement for the .NET Framework.
1. .NET Core Saturday 2016 – 22.10.2016
Introduction
to .NET Core
Marco Parenzan
Microsoft MVP for Azure
@marco_parenzan
2. .NET Core Saturday 2016 – 22.10.2016
@marco_parenzan
◇Microsoft MVP 2016 for Azure
◇Azure Trainer in Cloud Academy, Inc.
◇Community Lead for 1nn0va
3. .NET Core Saturday 2016 – 22.10.2016
The need of a new
framework
It was 1996
4. .NET Core Saturday 2016 – 22.10.2016
Requirements in 1996
◇...starting after Java
◇JVMJitted Execution Engine
◇High cost per Mb
◇Raising Internet, not Cloud
◇COM3 and Visual Basic 6 needed a successor
◇Windows Only (no MacOS, no Linux n°1 Cloud OS)
5. .NET Core Saturday 2016 – 22.10.2016
.NET in 2001
◇https://channel9.msdn.com/Blogs/Seth-Juarez/What-is-NET-Standard
◇«Drag&Drop a button...»
.NET FX
Win Form
ASP.NET
WebForm
C# VB.NET
6. .NET Core Saturday 2016 – 22.10.2016
The need of a new
framework
It was 2012
7. .NET Core Saturday 2016 – 22.10.2016
Requirements in 2012
Cloud First
Portability
New
Architectures
New
Languages
Node.js
Tooling
New
Deployments
Command
Line Open Source
Coding Tools
Breaking
Changes
8. .NET Core Saturday 2016 – 22.10.2016
Cloud First
◇Azure and other cloud providers
◇High densityLight, Highly optimized
9. .NET Core Saturday 2016 – 22.10.2016
Portability
◇Windows and Linux on Cloud
◇Windows and MacOS on desktop
◇iOS and Android on smartphone
◇«........(ARM) (x86)» on Internet of Things
10. .NET Core Saturday 2016 – 22.10.2016
Open Source
◇Open Source standards
◇Contributions from community
◇GitHub
11. .NET Core Saturday 2016 – 22.10.2016
Mono
◇Open Source implementation of the standardized Common Language
Infrastructure
■http://www.mono-project.com/docs/about-mono/languages/ecma/
◇Anticipated, inspired, what .NET should be (example: C# REPL), multiplatform
◇Xamarin
12. .NET Core Saturday 2016 – 22.10.2016
New Architectures
◇Successful ARM for Smartphones and Internet of Things has changed the scenario
◇ARM is small footprint (memory, CPU power)
■No more runtime, but native compilation, architecture specific
13. .NET Core Saturday 2016 – 22.10.2016
New languages
◇JavaScript, ECMAScript, Node.js and TypeScript
◇More Python than Java
◇Go
◇R
16. .NET Core Saturday 2016 – 22.10.2016
Command Line
◇Bash and Powershell
◇Azure and AWS
◇Docker
17. .NET Core Saturday 2016 – 22.10.2016
Coding Tools
◇IDEVisual Studio (Full) for Windows
◇EditorVisual Studio Code for Windows, Linux and MacOS
18. .NET Core Saturday 2016 – 22.10.2016
Breaking changes
◇Support Statement for Visual Basic 6.0 on Windows Vista, Windows Server 2008,
Windows 7, Windows 8 and Windows 8.1, Windows Server 2012, and Windows 10
■https://msdn.microsoft.com/en-us/vstudio/ms788708.aspx
◇Contrast that with the Microsoft .NET Framework 1.0 (2002), which is incompatible
with Windows 7 (2009)
■https://msdn.microsoft.com/en-us/magazine/jj133828.aspx
◇No more .NET frameworks major versions after 4.x
■Only in-place replacements
19. .NET Core Saturday 2016 – 22.10.2016
What is .NET Core
Time for a new .NET
21. .NET Core Saturday 2016 – 22.10.2016
What is .NET?
◇Common Language Runtime (CLR)
■Services common for all language implementers (Type System, language feaures
like inheritance, generics, interfaces, and overloading for object-oriented
programming). Async Programming, Threading, Structured Exception Handling,
Attributes, Garbage Collection, Delegates)
◇Intermediate Language (IL)
■The generated code from each language compiler
◇Common Language Specifications (CLS)
■The rules to follow to be interoperable among languages
◇Base Class Library
■A set of types (System.Object, System.Int32, System.String, System.IO.*, …) common
to all .NET
◇Framework
■The implementation of all of these…
22. .NET Core Saturday 2016 – 22.10.2016
Portable Class Libraries
◇The environment is a synthetic one that is generated by the intersection of a set of
concrete .NET platforms. This means that exposed APIs and platform assumptions
are a subset of what would be available to a platform-specific library.
◇You choose a platform configuration when you create a portable library. These are
the set of platforms that you need to support (for example, .NET Framework 4.5+,
Windows Phone 8.0+). The more platforms you opt to support, the fewer APIs and
fewer platform assumptions you can make, the lowest common denominator. This
characteristic can be confusing at first, since people often think “more is better”, but
find that more supported platforms results in fewer available APIs.
23. .NET Core Saturday 2016 – 22.10.2016
What is .NET Core (2)
Again...Time for a new .NET
24. .NET Core Saturday 2016 – 22.10.2016
What is .NET Core?
◇A new .NET CLR
◇A set of new libraries
◇A set of SDK tools and language compilers
◇The 'dotnet' app host
25. .NET Core Saturday 2016 – 22.10.2016
What is .NET Core?
◇Objectives
■Modular and smaller implementation of .NET
■Cross-platform
■App-level isolation
■Built in the open
■Optimized for specific workloads (Cloud)
■Built for the next ten years of software development
◇.NET Codebase Fork
■No compromises on retrocompatibility
■Versioning and dependencing issues
26. .NET Core Saturday 2016 – 22.10.2016
.NET Core Application Models
◇Console application
◇Completly rewritten ASP.NET to support Cloud
■x64 first scenario
◇Universal Windows Platform: Windows Store Apps (cross-device)
27. .NET Core Saturday 2016 – 22.10.2016
Breaking changes
◇No Global Assembly Cache
■All assemblies are deployed privately
■An assembly for each namespace (no
more mscorelib.dll)
◇No application models
■WPF
■Winforms
■WebForms
◇Anything Windows-specific
■registry, ACLs, perf counters, etc.
◇No AppDomains
■Infrastructure exists but it is no longer
usable in terms of API
■New AppContext object
■AssemblyLoadContext to dynamically
load assemblies
■Container to isolate code
◇No Remoting
◇No Binary Serialization
◇No Code Access Security (CAS)
28. .NET Core Saturday 2016 – 22.10.2016
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
31. .NET Core Saturday 2016 – 22.10.2016
• Codebase Fork
• Need implementations of new capabilities on each platform
• Need to align with different ship cycles (e.g., Windows for
.NET Framework)
• Key API’s are not present on all platforms
• Different implementations on each platform
• Need to target a small common denominator to reuse code
• Need to master 3 base class libraries
.NET today—challenges
Developers
Platforms
35. .NET Core Saturday 2016 – 22.10.2016
.NET Standard Library
◇Starting from PCL purposes
◇Common functionalities among choosen platform at compile time
◇Runtime library contracts
◇Set of reference assemblies
◇Binary compatibility
◇NuGet packages idenfified by «moniker» (ex. «netstandard1.6»)
■don’t need to specify all supported runtimes: net45+wp80+win8+wpa81+dnxcore50
■Netstandard 1.4: target Fx 4.6, Core 1.0, UWP, Mono
■Netstandard 1.2: target Fx 4.5, Windows Phone 8, etc.
◇So it can run on any Runtime complaining standard
◇https://github.com/dotnet/corefx/blob/master/Documentation/architecture/net-
platform-standard.md
36. .NET Core Saturday 2016 – 22.10.2016
.NET Platforms
Target Platform Name Alias Versions
.NET Platform Standard netstandard 1.0 1.1 1.2 1.3 1.4 1.5 1.6
.NET Core netcoreapp 1.0
.NET Framework net 4.6.3
4.6.2
4.6.1
4.6
4.5.2
4.5.1
4.5
Universal Windows Platform uap 10.0
Windows win 8.1
8.0
Windows Phone wpa 8.1
Windows Phone Silverlight wp 8.1
8.0
Mono/Xamarin Platforms *
Mono *
37. .NET Core Saturday 2016 – 22.10.2016
.NET Core Runtimes
◇Runtime Adaptation Layer
■Specific layer to complete platform specific implementation
◇Runtime Identifier RID
■Identifies Operative System
■https://docs.microsoft.com/en-us/dotnet/articles/core/rid-catalog
38. .NET Core Saturday 2016 – 22.10.2016
Runtime Identifier RID
•Windows 7 / Windows Server 2008 R2
•win7-x64
•win7-x86
•Windows 8 / Windows Server 2012
•win8-x64
•win8-x86
•win8-arm
•Windows 8.1 / Windows Server 2012 R2
•win81-x64
•win81-x86
•win81-arm
•Windows 10 / Windows Server 2016
•win10-x64
•win10-x86
•win10-arm
•win10-arm64
•Red Hat Enterprise Linux
•rhel.7.0-x64
•rhel.7.1-x64
•rhel.7.2-x64
•Ubuntu
•ubuntu.14.04-x64
•ubuntu.14.10-x64
•ubuntu.15.04-x64
•ubuntu.15.10-x64
•ubuntu.16.04-x64
•ubuntu.16.10-x64
•CentOS
•centos.7-x64
•Debian
•debian.8-x64
•Fedora
•fedora.23-x64
•fedora.24-x64
•osx.10.10-x64
•osx.10.11-x64
•osx.10.12-x64
•OpenSUSE
•opensuse.13.2-x64
•opensuse.42.1-x64
•Oracle Linux
•ol.7-x64
•ol.7.0-x64
•ol.7.1-x64
•ol.7.2-x64
•Currently supported Ubuntu derivatives
•linuxmint.17-x64
•linuxmint.17.1-x64
•linuxmint.17.2-x64
•linuxmint.17.3-x64
•linuxmint.18-x64
WINDOWS RIDS LINUX RIDS
WINDOWS RIDS
41. .NET Core Saturday 2016 – 22.10.2016
Next gen JIT (RyuJIT)
SIMD
Runtime
Components Compilers
Languages innovation
.NET Compiler Platform
.NET Core 5 Libraries
.NET Framework 4.6 Libraries
NuGet packages
.NET Framework 4.6 .NET Core
What’s common, and what’s not?
42. .NET Core Saturday 2016 – 22.10.2016
.NET Compilers
◇The C# and F# languages (Visual Basic is coming)
◇C# 6.0 is the same (road to 7.0)
◇Integrated into several text editors and IDEs
◇Roslyn: open-source C# and Visual Basic compilers with rich code analysis APIs
43. .NET Core Saturday 2016 – 22.10.2016
Compilers and runtimes in action
◇JIT: Just-in-Time
Fast compilation during runtime
◇AOT: Ahead of Time
Highly optimized machine code during build
CoreRT
.NET
Native
Compiler
Single binary
64 bit native code
CoreCLR
RyuJIT
.NET assemblies
IL code
Roslyn
Compiler
Platform
Build
AOT
Native
codeJIT
CoreFX
44. .NET Core Saturday 2016 – 22.10.2016
CoreCLR
◇CoreCLR is the new runtime environment used by ASP.NET and the Console
Application
◇It uses new RyuJIT. Includes basic services and Garbage Collector
◇It's faster and produces optimized code (SIMD, Vectorization, etc.)
◇https://github.com/dotnet/coreclr
45. .NET Core Saturday 2016 – 22.10.2016
CoreRT
◇CoreRT is another used by UWP
◇.NET Native generates all the native code and is free from all addictions
◇UWP uses the CoreCLR during debugging and .NET Native in Release
◇.NET is a Ahead of Time (AOT) compiler
◇Native compilation uses the backend compiler in Visual C++
◇https://github.com/dotnet/corert
◇Pro
■Less boot time, less RAM
■Better performances
■Less battery
◇Cons:
■Compile Time
■Linq interpreted
46. .NET Core Saturday 2016 – 22.10.2016
CoreFX
◇It includes classes for collections, file systems, console, XML, async and many
others
◇https://github.com/dotnet/corefx
■This repo contains the .NET Core foundational libraries
48. .NET Core Saturday 2016 – 22.10.2016
Acquisition
◇NET Core is distributed in two main ways, as packages on NuGet.org and as
standalone distributions.
◇You can download .NET Core at https://www.microsoft.com/net/download
◇The Microsoft .NET Core SDK distribution includes .NET Core and a set of tools
◇.NET Core Packages contain the .NET Core runtime and libraries.
49. .NET Core Saturday 2016 – 22.10.2016
Developer Environments
◇Your choice of tool, on your choice platform
■Visual Studio on Windows
■Visual Studio Code on Mac, Linux, or Windows
■vi or emacs
50. .NET Core Saturday 2016 – 22.10.2016
Text before UI
◇Everything from text files
■Projects
■Configuration
■Preferences and options
■Launch settings
◇JSON is preferred
data format
51. .NET Core Saturday 2016 – 22.10.2016
dotnet.exe Command Line
◇dotnet new
◇dotnet restore
◇dotnet run
◇dotnet build
◇dotnet build –native
◇dotnet test
◇dotnet pack
◇dotnet deploy
52. .NET Core Saturday 2016 – 22.10.2016
Testing
◇xUnit was first, now NUnit, MsTest
◇Secondary test libraries (mocking, functional testing, etc.) in progress
◇Add following NUGET packages: xunit, dotnet-test-xunit
Run tests:
dotnet test
54. .NET Core Saturday 2016 – 22.10.2016
New project system
◇Independent of Visual Studio
◇JSON files instead of VS artefacts
◇Every file is relevant
■Unless stated otherwise
◇Specific folder structure
◇Build for multiple target frameworks
◇.xproj for Visual Studio (for now)
◇C:Program Files (x86)Microsoft SDKsNuGetPackages
55. .NET Core Saturday 2016 – 22.10.2016
NuGet all the things
◇NuGet packages are unit of reference
■Not assemblies
◇Projects will:
■build NuGet packages
■reference NuGet packages
56. .NET Core Saturday 2016 – 22.10.2016
Global.json
◇Defines the SDK-s to be used in solution (projects)
◇SDK is installed in: C:Program Filesdotnetsdk
58. .NET Core Saturday 2016 – 22.10.2016
Framework Dependent Application
◇Framework Dependent Application
■Common .NET application type
■It requires preinstalled .NET framework to run
■Small footprint
◇Runtime in C:Program Filesdotnetsdk
59. .NET Core Saturday 2016 – 22.10.2016
Self Contained Applications
◇Precompiled for specific runtime
■win10-x64
■osx.10.10-x64
■ubuntu.14.04-x64
◇Includes runtime assemblies as a part of application
◇Does not need preinstalled framework
◇Big footprint.
◇Deployment is two-step process
■Build Executable shim
■Publish with runtime
60. .NET Core Saturday 2016 – 22.10.2016
Self-Contained Applications{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
// "type": "platform"
},
"netcorelib": "1.0.0-*"
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
},
"runtimes": {
"win10-x64": {},
"osx.10.10-x64": {},
"ubuntu.14.04-x64": {}
}
Remove this to
activate build of
executable.
Add wanted
runtimes. Or you
get an error.
61. .NET Core Saturday 2016 – 22.10.2016
Step I: Build executable shim
Build application:
C:AppFolder>dotnet build
Native shim code.
You application is
still here in DLL
When you run this it is
will load framework
assemblies from
installation folder. It is still
not self-contained
application
64. .NET Core Saturday 2016 – 22.10.2016
Conclusions
◇Coherent with new requirements
◇Learned from the community
◇Open
◇https://github.com/dotnet/core
◇Global vision for all .NET ecosystem
◇Support for all runtimes in future (.NET Full, Mono, Xamarin)
65. .NET Core Saturday 2016 – 22.10.2016
Any questions?
You can find me at: marco.parenzan@1nn0va.it
Thanks!
Editor's Notes
WPF, WinForms, even if the application isn’t going cross-platform, stay on .Net Fx. A migration to UWP is possible, but that means a rewrite of the UI in addition to the Core migration.
ASP.NET WebForms applications should remain on .NET Fx.
On the other hand, MVC applications, micro-services, console apps, and anything that can benefit in being deployed cross-platform, especially using containers, is an excellent choice.
General purpose libraries should definitely be ported and support both Core and Fx.
NET Core is distributed in two main ways, as packages on NuGet.org and as standalone distributions.
You can download .NET Core at the .NET Core Getting Started page. The Microsoft .NET Core distribution includes the CoreCLR runtime, associated libraries, a console application host and the dotnet app launcher. It is described by the Microsoft.NETCore.App metapackage.
The Microsoft .NET Core SDK distribution includes .NET Core and a set of tools for restoring NuGet packages and compiling and building apps. Typically, you will first install the .NET Core SDK to get started with .NET Core development. You may choose to install additional .NET Core (perhaps pre-release) builds.
.NET Core Packages contain the .NET Core runtime and libraries (reference assemblies and implementations), for example, System.Net.Http.
.NET Core Metapackages describe various layers and app-models by referencing the appropriate set of versioned library packages.
Dotnet build, in the case of an app, generates runnable assets by copying an executable host.