Upload
marco-parenzan
View
313
Download
2
Embed Size (px)
Citation preview
.NET Core Saturday 2016 – 22.10.2016
Introduction to .NET Core
Marco ParenzanMicrosoft MVP for Azure
@marco_parenzan
.NET Core Saturday 2016 – 22.10.2016
@marco_parenzan◇ Microsoft MVP 2016 for Azure
◇ Azure Trainer in Cloud Academy, Inc.
◇ Community Lead for 1nn0va
.NET Core Saturday 2016 – 22.10.2016
The need of a new frameworkIt was 1996
.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)
.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.NETWebForm
C# VB.NET
.NET Core Saturday 2016 – 22.10.2016
The need of a new frameworkIt was 2012
.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
.NET Core Saturday 2016 – 22.10.2016
Cloud First◇ Azure and other cloud providers◇ High densityLight, Highly optimized
.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
.NET Core Saturday 2016 – 22.10.2016
Open Source◇ Open Source standards◇ Contributions from community◇ GitHub
.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
.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
.NET Core Saturday 2016 – 22.10.2016
New languages◇ JavaScript, ECMAScript, Node.js and TypeScript◇ More Python than Java◇ Go◇ R
.NET Core Saturday 2016 – 22.10.2016
Node.js Tooling◇ Node.js◇ NPM◇ JavaScript V8
.NET Core Saturday 2016 – 22.10.2016
New deployments◇ Application Lifecycle Management
■ Source Code Management■ Continuous Integration■ Continuous Delivery■ Testing
◇ Containerization and Docker◇ Microservices
.NET Core Saturday 2016 – 22.10.2016
Command Line◇ Bash and Powershell◇ Azure and AWS◇ Docker
.NET Core Saturday 2016 – 22.10.2016
Coding Tools◇ IDEVisual Studio (Full) for Windows◇ EditorVisual Studio Code for Windows, Linux and MacOS
.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
.NET Core Saturday 2016 – 22.10.2016
What is .NET CoreTime for a new .NET
.NET Core Saturday 2016 – 22.10.2016
What is .NETTime do to a recap
.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…
.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.
.NET Core Saturday 2016 – 22.10.2016
What is .NET Core (2)Again...Time for a new .NET
.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
.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
.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)
More will follow
.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)
.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
.NET Core Saturday 2016 – 22.10.2016
.NET FRAMEWORK .NET CORE XAMARINAP
PM
ODEL
SBA
SELI
BRAR
IES
Base Class Library Core Library Mono Class Library
ASP.NET
Windows FormsWPF UWP
ASP.NET Core
iOSAndroid
Compilers Languages Runtime components
COMMON INFRASTRUCTURE
OS X
.NET today—app models and libraries
.NET Core Saturday 2016 – 22.10.2016
.NET FRAMEWORK .NET CORE XAMARINAP
PM
ODEL
SBA
SELI
BRAR
IES
Compilers Languages Runtime components
COMMON INFRASTRUCTURE
PCL reference assemblies
Reference implementati
on
My code
Implementation 3Implementation
2Implementation 1
.NET today—reusing code
.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
.NET Core Saturday 2016 – 22.10.2016
.NET Standard Library
.NET Core Saturday 2016 – 22.10.2016
.NET ecosystem tomorrow .NET FRAMEWORK .NET CORE XAMARIN
.NET STANDARD LIBRARYOne library to rule them all
ASP.NET
Windows FormsWPF UWP
ASP.NET Core*
iOSAndroid
Compilers Languages Runtime components
COMMON INFRASTRUCTURE
OS X
.NET Core Saturday 2016 – 22.10.2016
.NET tomorrow—.NET Core today .NET FRAMEWORK .NET CORE XAMARIN
Compilers Languages Runtime components
COMMON INFRASTRUCTURE
My codeFull implementations
Reference implementations
.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/n
et-platform-standard.md
.NET Core Saturday 2016 – 22.10.2016
.NET PlatformsTarget 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.24.6.1
4.64.5.24.5.1
4.5Universal Windows Platform uap 10.0Windows win 8.1
8.0Windows Phone wpa 8.1Windows Phone Silverlight wp 8.1
8.0Mono/Xamarin Platforms *Mono *
.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
.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
.NET Core Saturday 2016 – 22.10.2016
.NET tomorrow—.NET Core today .NET FRAMEWORK .NET CORE XAMARIN
Compilers Languages Runtime components
COMMON INFRASTRUCTURE
My codeFull implementations (.NET Runtime)
Reference implementations (.NET Standard)
.NET Core Saturday 2016 – 22.10.2016
.NET Core Runtime
.NET Core Saturday 2016 – 22.10.2016
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?
.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
.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 binary64 bit native code
CoreCLR
RyuJIT
.NET assembliesIL code
Roslyn Compiler Platform
Build
AOT
Native codeJIT
CoreFX
.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
.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 More will follow
.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
.NET Core Saturday 2016 – 22.10.2016
Tools
.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.
.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
.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
.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
Scaffolds a minimal appRestores packages for the project
Compiles and runs the appCompiles to IL
Compiles to a single executable
Run unit tests
Create nuget packages
Publish packages
.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
.NET Core Saturday 2016 – 22.10.2016
Application Types
.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 SDKs\NuGetPackages
.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
.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 Files\dotnet\sdk
.NET Core Saturday 2016 – 22.10.2016
Project.json{ "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" } }}
.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 Files\dotnet\sdk
.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
.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.
.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
.NET Core Saturday 2016 – 22.10.2016
Step II: Build Self-Contained ApplicationBuild application:C:\AppFolder>dotnet build
Build application:C:\AppFolder>dotnet publish –r win10-x64C:\AppFolder>dotnet publish –r win10-x86C:\AppFolder>dotnet publish –r ubuntu.14.04-x64C:\AppFolder>dotnet publish –r ubuntu.14.04-x64
All framework assemblies are deployed
with application.
.NET Core Saturday 2016 – 22.10.2016
Conclusions
.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)