SlideShare a Scribd company logo
Tamir Dresher
@tamir_dresher
Demystifying the Core of .NET Core
1
@tamir_dresher
.NET Core
Finally
2
3
• Software architect, consultant and instructor
• Software Engineering Lecturer @ Ruppin Academic Center
• Author of Rx.NET in Action (Manning)
@tamir_dresher
http://www.TamirDresher.com.
About Me
3
@tamir_dresher
Agenda
• What is .NET Core
• .NET Core application Core components
• .NET Core Deployment Models
• Sharing code with .NET Standard
4
@tamir_dresher
What’s .NET Core
• A new implementation of .NET – modular, performant, seperated
• Cross Platform and Cross Devices
• Allows side-by-side execution
• Pay-for-play model – only “pay” for the part of CoreFx you use
• Open source:
• Github.com/dotnet
• https://github.com/dotnet/corefx
• https://github.com/dotnet/core
@tamir_dresher
Full .NET dev process - build
7
using System;
namespace testproj
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
.method private hidebysig static
void Main (
string[] args
) cil managed
{
// Method begins at RVA 0x2050
// Code size 13 (0xd)
.maxstack 8
.entrypoint
IL_0000: nop
IL_0001: ldstr "Hello World!"
IL_0006: call void [System.Console]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ret
} // end of method Program::Main
csc
mscorlib.dll
reference
[app].dll/*.exe*.cs
@tamir_dresher
Full .NET dev process - execution
8
.method private hidebysig static
void Main (
string[] args
) cil managed
{
// Method begins at RVA 0x2050
// Code size 13 (0xd)
.maxstack 8
.entrypoint
IL_0000: nop
IL_0001: ldstr "Hello World!"
IL_0006: call void [System.Console]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ret
} // end of method Program::Main
mscorlib.dll
load
[app].dll/*.exe
JIT
Loader
(Fusion)
GC
1. MSCorEE.dll
2. C:Windows
Microsoft.NET
Framework64
[version]
clr.dll
Load and run
CLR
...
@tamir_dresher
.NET Core
• .NET Core runtime – contains the CoreCLR. exist for each supported platform
• Location: C:Program FilesdotnetsharedMicrosoft.NETCore.App
• .NET Core SDK – tooling, templates, packages cache + the runtime
• Location: C:Program Filesdotnetsdk
• .NET Core CLI - command-line (CLI) tools, used for building .NET Core apps and
libraries
• https://www.microsoft.com/net/download/all
9
@tamir_dresher
Full .NET dev process - build
10
using System;
namespace testproj
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
.method private hidebysig static
void Main (
string[] args
) cil managed
{
// Method begins at RVA 0x2050
// Code size 13 (0xd)
.maxstack 8
.entrypoint
IL_0000: nop
IL_0001: ldstr "Hello World!"
IL_0006: call void [System.Console]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ret
} // end of method Program::Main
dotnet build
Microsoft.NETCore.App
reference
[app].dll*.cs
[app].runtimeconfig.json [app].runtimeconfig.dev.json
[app].deps.json
@tamir_dresher
Full .NET dev process - execution
11
.method private hidebysig static
void Main (
string[] args
) cil managed
{
// Method begins at RVA 0x2050
// Code size 13 (0xd)
.maxstack 8
.entrypoint
IL_0000: nop
IL_0001: ldstr "Hello World!"
IL_0006: call void [System.Console]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ret
} // end of method Program::Main
CoreFX
load
app.dll
JIT
Loader
(Fusion)
GC
dotnet-core
Runtime
Load and run
CoreCLR
...
> dotnet app.dll
[app].runtimeconfig.json [app].runtimeconfig.dev.json
[app].deps.json
configuration
reads
Demo
Creating a .NET Core console app and running in windows and linux
12
@tamir_dresher
.NET Core Build Artifacts
13
Dependencies Manifest
Runtime configuration
Optional configuration
@tamir_dresher
Changing runtime configuration
• In Full .NET Some configuration were only possible in app/machine.config (e.g.
changing the gc)
• app/machine.config is gone, user *.runtimeconfig.json instead
• Full list of configuration properties for CoreCLR
14
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>
</Project>
{
"runtimeOptions": {
...
},
"configProperties": {
"System.GC.Server": true
}
}
}
[project].csproj [project].runtimeconfig.json
@tamir_dresher
Controlling the runtime version
• The global.json file allows selection of the .NET Core tools version being used
through the sdk property.
• .NET Core CLI tools look for this file in the current working directory, or one of
its parent directories.
15
…
--- Resolving dotnet from working dir
Probing path [c:tempnewprojbinDebugnetcoreapp2.1global.json] for global.json
Probing path [c:tempnewprojbinDebugglobal.json] for global.json
Probing path [c:tempnewprojbinglobal.json] for global.json
Probing path [c:tempnewprojglobal.json] for global.json
Probing path [c:tempglobal.json] for global.json
Probing path [c:global.json] for global.json
Terminating global.json search at [c:]
…
> SET COREHOST_TRACE=1
> dotnet app.dll
{
"sdk": { "version": "1.0.0-preview2-003121" }
}
@tamir_dresher
Types of .NET Core applications deployments
• Requires .NET Core Runtime on the target system.
• Portable between installations of .NET Core.
• Executed by running the dotnet utility.
For example, dotnet app.dll
16
Framework
Dependent
Deployment
(FDD)
Self
Contained
Deployment
(SCD)
• .NET Core libraries and Runtime, are included with the
application
• Isolated from other .NET Core applications.
• Include A renamed version of the platform-specific .NET
Core host (such as app.exe on Windows) which then runs
the actual app.dll
@tamir_dresher
Self Contained Deployment (SCD)
17
1. Add the Runtime Identifiers (RID) to the csproj
• https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#windows-rids
2. Publish the project to the target platform
<PropertyGroup>
<RuntimeIdentifiers>win10-x64;osx.10.11-x64</RuntimeIdentifiers>
</PropertyGroup>
> dotnet publish -c Release -r win10-x64
> dotnet publish -c Release -r osx.10.11-x64
@tamir_dresher
Self Contained Deployment (SCD)
18
1. Add the Runtime Identifiers (RID) to the csproj
• https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#windows-rids
2. Publish the project to the target platform
<PropertyGroup>
<RuntimeIdentifiers>win10-x64;osx.10.11-x64</RuntimeIdentifiers>
</PropertyGroup>
> dotnet publish -c Release -r win10-x64
> dotnet publish -c Release -r osx.10.11-x64
Demo
Self-contained deployment
19
Creating reusable
libraries with .NET
Standard
20
@tamir_dresher
The problem
21
.NET Framework .NET Core Xamarin(Mono)
WinForms
WPF
ASP.NET
UWP
Console
ASP.NET
Core
iOS
OS X
Android
Framework Class
Library (FCL) CoreFX Mono Class Library
MyLib.dll
?
@tamir_dresher
Possible Solution – portable Class Library (PCL)
22
.NET 4.5
Silverlight
5
Windows
8
Profile47
@tamir_dresher
Possible Solution – portable Class Library (PCL)
23
.NET 4.5
Silverlight
5
Windows
8
Profile47
@tamir_dresher 24
@tamir_dresher 25
@tamir_dresher
A better solution - .NET Standard
.NET Framework .NET Core Xamarin(Mono)
WinForms
WPF
ASP.NET
UWP
Console
ASP.NET
Core
UWP
Console
ASP.NET
Core
Framework Class
Library (FCL) CoreFX Mono Class Library.NET Standard
@tamir_dresher
A better solution - .NET Standard
• A Spec (Standard) supported by all .NET implementations (Currently 2.0)
• .NET Standard is a set of APIs that all .NET platforms have to implement. This
unifies the .NET platforms and prevents future fragmentation.
• https://github.com/dotnet/standard
2.0
1.6
1.3
1.0
@tamir_dresher
How a .NET Standard works?
28
@tamir_dresher
.NET Standard Shim and Stubs – build time
30
@tamir_dresher
.NET Standard Shim and Stubs – build time
31
@tamir_dresher 32
%USERPROFILE%.nugetpackagesnetstandard.library2.0.1buildnetstandard2.0ref
.NET Standard Shim and Stubs – build time
@tamir_dresher
.NET Standard Shim and Stubs – runtime
33
@tamir_dresher
.NET Standard Shim and Stubs – runtime
34
[install dir]dotnetsharedMicrosoft.NETCore.App2.1.0-preview1-26216-03
@tamir_dresher
.NET Standard Shim and Stubs – runtime
35
[install dir]dotnetsharedMicrosoft.NETCore.App2.1.0-preview1-26216-03
@tamir_dresher
Summary
• What is .NET Core – cross platform .NET
• .NET Core application Core components
• SDK, Runtime
• Artifacts - *.runtimeconfig.{dev}.json, *. deps.json
• .NET Core Deployment Models – FDD, SCD
• Sharing code with .NET Standard
• PCL vs .NET Standard
• NETStandard.Library, netstandard.dll shim and stubs
36
Thank You
38
@tamir_dresher
http://www.TamirDresher.com.
@tamir_dresher
@tamir_dresher
The Runtime Package Store
• A local repository of pre-downloaded nuged packages
• The new GAC
• dotnet
store
x64
netcoreapp2.0
microsoft.applicationinsights
microsoft.aspnetcore
...
x86
netcoreapp2.0
microsoft.applicationinsights
microsoft.aspnetcore
...
40
@tamir_dresher
The Runtime Package Store
41
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Moq" Version="4.7.63" />
</ItemGroup>
</Project>
dotnet store
--manifest packages.csproj
--runtime win 10-x64
--framework netcoreapp 2.0
--framework-version 2.0.0
<StoreArtifacts>
<Package Id="Newtonsoft.Json" Version="10.0.3" />
<Package Id="Castle.Core" Version="4.1.0" />
<Package Id="Moq" Version="4.7.63" />
</StoreArtifacts>
@tamir_dresher
The Runtime Package Store
• You can configure your project to use a Runtime Package Restore
• dotnet publish --manifest <PATH_TO_MANIFEST_FILE>
42

More Related Content

What's hot (20)

PDF
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
gree_tech
 
PPTX
How We Test Linux
GlobalLogic Ukraine
 
PDF
Bypassing patchguard on Windows 8.1 and Windows 10
Honorary_BoT
 
PPTX
Composer JSON kills make files
ropsu
 
PDF
DCSF 19 eBPF Superpowers
Docker, Inc.
 
PDF
TFLite NNAPI and GPU Delegates
Koan-Sin Tan
 
PDF
Terraform AWS modules and some best practices - September 2019
Anton Babenko
 
PPTX
Injection on Steroids: Codeless code injection and 0-day techniques
enSilo
 
PDF
Process injection - Malware style
Sander Demeester
 
PPTX
Dockerizing a Symfony2 application
Roman Rodomansky
 
PDF
Borland star team to tfs simple migration
Shreesha Rao
 
PPTX
Composer | PHP Dependency Manager
Ujjwal Ojha
 
PDF
Php Dependency Management with Composer ZendCon 2016
Clark Everetts
 
PDF
Dockerizing Symfony Applications - Symfony Live Berlin 2014
D
 
PDF
Fluentd v0.14 Overview
N Masahiro
 
PPTX
Python at Facebook
Angelo Failla
 
PPTX
[若渴計畫] Black Hat 2017之過去閱讀相關整理
Aj MaChInE
 
PDF
Deliver Python Apps with Docker
Anton Egorov
 
ODP
Docker for Developers
Chris Tankersley
 
PDF
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Ontico
 
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
gree_tech
 
How We Test Linux
GlobalLogic Ukraine
 
Bypassing patchguard on Windows 8.1 and Windows 10
Honorary_BoT
 
Composer JSON kills make files
ropsu
 
DCSF 19 eBPF Superpowers
Docker, Inc.
 
TFLite NNAPI and GPU Delegates
Koan-Sin Tan
 
Terraform AWS modules and some best practices - September 2019
Anton Babenko
 
Injection on Steroids: Codeless code injection and 0-day techniques
enSilo
 
Process injection - Malware style
Sander Demeester
 
Dockerizing a Symfony2 application
Roman Rodomansky
 
Borland star team to tfs simple migration
Shreesha Rao
 
Composer | PHP Dependency Manager
Ujjwal Ojha
 
Php Dependency Management with Composer ZendCon 2016
Clark Everetts
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
D
 
Fluentd v0.14 Overview
N Masahiro
 
Python at Facebook
Angelo Failla
 
[若渴計畫] Black Hat 2017之過去閱讀相關整理
Aj MaChInE
 
Deliver Python Apps with Docker
Anton Egorov
 
Docker for Developers
Chris Tankersley
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Ontico
 

Similar to Tamir Dresher - Demystifying the Core of .NET Core (20)

PDF
.NET Core Blimey! (dotnetsheff Jan 2016)
citizenmatt
 
PDF
.NET Core, ASP.NET Core Course, Session 1
Amin Mesbahi
 
PPTX
Unpacking .NET Core | EastBanc Technologies
EastBanc Tachnologies
 
PDF
Raffaele Rialdi
CodeFest
 
PPTX
Key Steps in Developing .NET Core Applications
Damir Dobric
 
PPTX
What should you know about Net Core?
Damir Dobric
 
PDF
.NET Core Blimey! Windows Platform User Group, Manchester
citizenmatt
 
PDF
Introduction to dot net
QIANG XU
 
PDF
Dot NET Core Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
.NET Core Blimey! (Shropshire Devs Mar 2016)
citizenmatt
 
PDF
Learn .NET Core - Introduction
Eng Teong Cheah
 
PPTX
.NET Core: a new .NET Platform
Alex Thissen
 
PPTX
Overview of the new .NET Core and .NET Platform Standard
Alex Thissen
 
PDF
.net Core Blimey - Smart Devs UG
citizenmatt
 
PPTX
Academy PRO: .NET Core intro
Binary Studio
 
PDF
.Net Core Blimey! (16/07/2015)
citizenmatt
 
PPTX
Net core
Damir Dobric
 
PPTX
.NET - The Current Spectrum
Rasik Bihari Tiwari
 
PPTX
Dive into .Net Core framework
ElifTech
 
PPTX
Introduction to .NET Core & ASP.NET Core MVC
Saineshwar bageri
 
.NET Core Blimey! (dotnetsheff Jan 2016)
citizenmatt
 
.NET Core, ASP.NET Core Course, Session 1
Amin Mesbahi
 
Unpacking .NET Core | EastBanc Technologies
EastBanc Tachnologies
 
Raffaele Rialdi
CodeFest
 
Key Steps in Developing .NET Core Applications
Damir Dobric
 
What should you know about Net Core?
Damir Dobric
 
.NET Core Blimey! Windows Platform User Group, Manchester
citizenmatt
 
Introduction to dot net
QIANG XU
 
Dot NET Core Interview Questions PDF By ScholarHat
Scholarhat
 
.NET Core Blimey! (Shropshire Devs Mar 2016)
citizenmatt
 
Learn .NET Core - Introduction
Eng Teong Cheah
 
.NET Core: a new .NET Platform
Alex Thissen
 
Overview of the new .NET Core and .NET Platform Standard
Alex Thissen
 
.net Core Blimey - Smart Devs UG
citizenmatt
 
Academy PRO: .NET Core intro
Binary Studio
 
.Net Core Blimey! (16/07/2015)
citizenmatt
 
Net core
Damir Dobric
 
.NET - The Current Spectrum
Rasik Bihari Tiwari
 
Dive into .Net Core framework
ElifTech
 
Introduction to .NET Core & ASP.NET Core MVC
Saineshwar bageri
 
Ad

More from Tamir Dresher (20)

PPTX
Engineering tools for making smarter decisions .pptx
Tamir Dresher
 
PDF
NET Aspire - NET Conf IL 2024 - Tamir Dresher.pdf
Tamir Dresher
 
PPTX
Tamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher
 
PPTX
Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher
 
PPTX
Tamir Dresher - Async Streams in C#
Tamir Dresher
 
PPTX
Anatomy of a data driven architecture - Tamir Dresher
Tamir Dresher
 
PPTX
Tamir Dresher Clarizen adventures with the wild GC during the holiday season
Tamir Dresher
 
PDF
Debugging tricks you wish you knew Tamir Dresher - Odessa 2019
Tamir Dresher
 
PDF
From zero to hero with the actor model - Tamir Dresher - Odessa 2019
Tamir Dresher
 
PPTX
Breaking the monolith to microservice with Docker and Kubernetes (k8s)
Tamir Dresher
 
PPTX
.Net december 2017 updates - Tamir Dresher
Tamir Dresher
 
PPTX
Testing time and concurrency Rx
Tamir Dresher
 
PPTX
Building responsive application with Rx - confoo - tamir dresher
Tamir Dresher
 
PPTX
.NET Debugging tricks you wish you knew tamir dresher
Tamir Dresher
 
PPTX
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
Tamir Dresher
 
PPTX
Building responsive applications with Rx - CodeMash2017 - Tamir Dresher
Tamir Dresher
 
PPTX
Debugging tricks you wish you knew - Tamir Dresher
Tamir Dresher
 
PPTX
Rx 101 - Tamir Dresher - Copenhagen .NET User Group
Tamir Dresher
 
PPTX
Cloud patterns - NDC Oslo 2016 - Tamir Dresher
Tamir Dresher
 
PPTX
Reactiveness All The Way - SW Architecture 2015 Conference
Tamir Dresher
 
Engineering tools for making smarter decisions .pptx
Tamir Dresher
 
NET Aspire - NET Conf IL 2024 - Tamir Dresher.pdf
Tamir Dresher
 
Tamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher
 
Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher
 
Tamir Dresher - Async Streams in C#
Tamir Dresher
 
Anatomy of a data driven architecture - Tamir Dresher
Tamir Dresher
 
Tamir Dresher Clarizen adventures with the wild GC during the holiday season
Tamir Dresher
 
Debugging tricks you wish you knew Tamir Dresher - Odessa 2019
Tamir Dresher
 
From zero to hero with the actor model - Tamir Dresher - Odessa 2019
Tamir Dresher
 
Breaking the monolith to microservice with Docker and Kubernetes (k8s)
Tamir Dresher
 
.Net december 2017 updates - Tamir Dresher
Tamir Dresher
 
Testing time and concurrency Rx
Tamir Dresher
 
Building responsive application with Rx - confoo - tamir dresher
Tamir Dresher
 
.NET Debugging tricks you wish you knew tamir dresher
Tamir Dresher
 
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
Tamir Dresher
 
Building responsive applications with Rx - CodeMash2017 - Tamir Dresher
Tamir Dresher
 
Debugging tricks you wish you knew - Tamir Dresher
Tamir Dresher
 
Rx 101 - Tamir Dresher - Copenhagen .NET User Group
Tamir Dresher
 
Cloud patterns - NDC Oslo 2016 - Tamir Dresher
Tamir Dresher
 
Reactiveness All The Way - SW Architecture 2015 Conference
Tamir Dresher
 
Ad

Recently uploaded (20)

PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PPTX
How Odoo Became a Game-Changer for an IT Company in Manufacturing ERP
SatishKumar2651
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PPTX
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PDF
Executive Business Intelligence Dashboards
vandeslie24
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Human Resources Information System (HRIS)
Amity University, Patna
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
How Odoo Became a Game-Changer for an IT Company in Manufacturing ERP
SatishKumar2651
 
Import Data Form Excel to Tally Services
Tally xperts
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
Executive Business Intelligence Dashboards
vandeslie24
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 

Tamir Dresher - Demystifying the Core of .NET Core

  • 3. 3 • Software architect, consultant and instructor • Software Engineering Lecturer @ Ruppin Academic Center • Author of Rx.NET in Action (Manning) @tamir_dresher http://www.TamirDresher.com. About Me 3
  • 4. @tamir_dresher Agenda • What is .NET Core • .NET Core application Core components • .NET Core Deployment Models • Sharing code with .NET Standard 4
  • 5. @tamir_dresher What’s .NET Core • A new implementation of .NET – modular, performant, seperated • Cross Platform and Cross Devices • Allows side-by-side execution • Pay-for-play model – only “pay” for the part of CoreFx you use • Open source: • Github.com/dotnet • https://github.com/dotnet/corefx • https://github.com/dotnet/core
  • 6. @tamir_dresher Full .NET dev process - build 7 using System; namespace testproj { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } } .method private hidebysig static void Main ( string[] args ) cil managed { // Method begins at RVA 0x2050 // Code size 13 (0xd) .maxstack 8 .entrypoint IL_0000: nop IL_0001: ldstr "Hello World!" IL_0006: call void [System.Console]System.Console::WriteLine(string) IL_000b: nop IL_000c: ret } // end of method Program::Main csc mscorlib.dll reference [app].dll/*.exe*.cs
  • 7. @tamir_dresher Full .NET dev process - execution 8 .method private hidebysig static void Main ( string[] args ) cil managed { // Method begins at RVA 0x2050 // Code size 13 (0xd) .maxstack 8 .entrypoint IL_0000: nop IL_0001: ldstr "Hello World!" IL_0006: call void [System.Console]System.Console::WriteLine(string) IL_000b: nop IL_000c: ret } // end of method Program::Main mscorlib.dll load [app].dll/*.exe JIT Loader (Fusion) GC 1. MSCorEE.dll 2. C:Windows Microsoft.NET Framework64 [version] clr.dll Load and run CLR ...
  • 8. @tamir_dresher .NET Core • .NET Core runtime – contains the CoreCLR. exist for each supported platform • Location: C:Program FilesdotnetsharedMicrosoft.NETCore.App • .NET Core SDK – tooling, templates, packages cache + the runtime • Location: C:Program Filesdotnetsdk • .NET Core CLI - command-line (CLI) tools, used for building .NET Core apps and libraries • https://www.microsoft.com/net/download/all 9
  • 9. @tamir_dresher Full .NET dev process - build 10 using System; namespace testproj { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } } .method private hidebysig static void Main ( string[] args ) cil managed { // Method begins at RVA 0x2050 // Code size 13 (0xd) .maxstack 8 .entrypoint IL_0000: nop IL_0001: ldstr "Hello World!" IL_0006: call void [System.Console]System.Console::WriteLine(string) IL_000b: nop IL_000c: ret } // end of method Program::Main dotnet build Microsoft.NETCore.App reference [app].dll*.cs [app].runtimeconfig.json [app].runtimeconfig.dev.json [app].deps.json
  • 10. @tamir_dresher Full .NET dev process - execution 11 .method private hidebysig static void Main ( string[] args ) cil managed { // Method begins at RVA 0x2050 // Code size 13 (0xd) .maxstack 8 .entrypoint IL_0000: nop IL_0001: ldstr "Hello World!" IL_0006: call void [System.Console]System.Console::WriteLine(string) IL_000b: nop IL_000c: ret } // end of method Program::Main CoreFX load app.dll JIT Loader (Fusion) GC dotnet-core Runtime Load and run CoreCLR ... > dotnet app.dll [app].runtimeconfig.json [app].runtimeconfig.dev.json [app].deps.json configuration reads
  • 11. Demo Creating a .NET Core console app and running in windows and linux 12
  • 12. @tamir_dresher .NET Core Build Artifacts 13 Dependencies Manifest Runtime configuration Optional configuration
  • 13. @tamir_dresher Changing runtime configuration • In Full .NET Some configuration were only possible in app/machine.config (e.g. changing the gc) • app/machine.config is gone, user *.runtimeconfig.json instead • Full list of configuration properties for CoreCLR 14 <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp2.1</TargetFramework> <ServerGarbageCollection>true</ServerGarbageCollection> </PropertyGroup> </Project> { "runtimeOptions": { ... }, "configProperties": { "System.GC.Server": true } } } [project].csproj [project].runtimeconfig.json
  • 14. @tamir_dresher Controlling the runtime version • The global.json file allows selection of the .NET Core tools version being used through the sdk property. • .NET Core CLI tools look for this file in the current working directory, or one of its parent directories. 15 … --- Resolving dotnet from working dir Probing path [c:tempnewprojbinDebugnetcoreapp2.1global.json] for global.json Probing path [c:tempnewprojbinDebugglobal.json] for global.json Probing path [c:tempnewprojbinglobal.json] for global.json Probing path [c:tempnewprojglobal.json] for global.json Probing path [c:tempglobal.json] for global.json Probing path [c:global.json] for global.json Terminating global.json search at [c:] … > SET COREHOST_TRACE=1 > dotnet app.dll { "sdk": { "version": "1.0.0-preview2-003121" } }
  • 15. @tamir_dresher Types of .NET Core applications deployments • Requires .NET Core Runtime on the target system. • Portable between installations of .NET Core. • Executed by running the dotnet utility. For example, dotnet app.dll 16 Framework Dependent Deployment (FDD) Self Contained Deployment (SCD) • .NET Core libraries and Runtime, are included with the application • Isolated from other .NET Core applications. • Include A renamed version of the platform-specific .NET Core host (such as app.exe on Windows) which then runs the actual app.dll
  • 16. @tamir_dresher Self Contained Deployment (SCD) 17 1. Add the Runtime Identifiers (RID) to the csproj • https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#windows-rids 2. Publish the project to the target platform <PropertyGroup> <RuntimeIdentifiers>win10-x64;osx.10.11-x64</RuntimeIdentifiers> </PropertyGroup> > dotnet publish -c Release -r win10-x64 > dotnet publish -c Release -r osx.10.11-x64
  • 17. @tamir_dresher Self Contained Deployment (SCD) 18 1. Add the Runtime Identifiers (RID) to the csproj • https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#windows-rids 2. Publish the project to the target platform <PropertyGroup> <RuntimeIdentifiers>win10-x64;osx.10.11-x64</RuntimeIdentifiers> </PropertyGroup> > dotnet publish -c Release -r win10-x64 > dotnet publish -c Release -r osx.10.11-x64
  • 20. @tamir_dresher The problem 21 .NET Framework .NET Core Xamarin(Mono) WinForms WPF ASP.NET UWP Console ASP.NET Core iOS OS X Android Framework Class Library (FCL) CoreFX Mono Class Library MyLib.dll ?
  • 21. @tamir_dresher Possible Solution – portable Class Library (PCL) 22 .NET 4.5 Silverlight 5 Windows 8 Profile47
  • 22. @tamir_dresher Possible Solution – portable Class Library (PCL) 23 .NET 4.5 Silverlight 5 Windows 8 Profile47
  • 25. @tamir_dresher A better solution - .NET Standard .NET Framework .NET Core Xamarin(Mono) WinForms WPF ASP.NET UWP Console ASP.NET Core UWP Console ASP.NET Core Framework Class Library (FCL) CoreFX Mono Class Library.NET Standard
  • 26. @tamir_dresher A better solution - .NET Standard • A Spec (Standard) supported by all .NET implementations (Currently 2.0) • .NET Standard is a set of APIs that all .NET platforms have to implement. This unifies the .NET platforms and prevents future fragmentation. • https://github.com/dotnet/standard 2.0 1.6 1.3 1.0
  • 27. @tamir_dresher How a .NET Standard works? 28
  • 28. @tamir_dresher .NET Standard Shim and Stubs – build time 30
  • 29. @tamir_dresher .NET Standard Shim and Stubs – build time 31
  • 31. @tamir_dresher .NET Standard Shim and Stubs – runtime 33
  • 32. @tamir_dresher .NET Standard Shim and Stubs – runtime 34 [install dir]dotnetsharedMicrosoft.NETCore.App2.1.0-preview1-26216-03
  • 33. @tamir_dresher .NET Standard Shim and Stubs – runtime 35 [install dir]dotnetsharedMicrosoft.NETCore.App2.1.0-preview1-26216-03
  • 34. @tamir_dresher Summary • What is .NET Core – cross platform .NET • .NET Core application Core components • SDK, Runtime • Artifacts - *.runtimeconfig.{dev}.json, *. deps.json • .NET Core Deployment Models – FDD, SCD • Sharing code with .NET Standard • PCL vs .NET Standard • NETStandard.Library, netstandard.dll shim and stubs 36
  • 37. @tamir_dresher The Runtime Package Store • A local repository of pre-downloaded nuged packages • The new GAC • dotnet store x64 netcoreapp2.0 microsoft.applicationinsights microsoft.aspnetcore ... x86 netcoreapp2.0 microsoft.applicationinsights microsoft.aspnetcore ... 40
  • 38. @tamir_dresher The Runtime Package Store 41 <Project Sdk="Microsoft.NET.Sdk"> <ItemGroup> <PackageReference Include="Newtonsoft.Json" Version="10.0.3" /> <PackageReference Include="Moq" Version="4.7.63" /> </ItemGroup> </Project> dotnet store --manifest packages.csproj --runtime win 10-x64 --framework netcoreapp 2.0 --framework-version 2.0.0 <StoreArtifacts> <Package Id="Newtonsoft.Json" Version="10.0.3" /> <Package Id="Castle.Core" Version="4.1.0" /> <Package Id="Moq" Version="4.7.63" /> </StoreArtifacts>
  • 39. @tamir_dresher The Runtime Package Store • You can configure your project to use a Runtime Package Restore • dotnet publish --manifest <PATH_TO_MANIFEST_FILE> 42

Editor's Notes

  • #2: Hello everyone, thank you all for joining me today. In the next hour or so I'm going to talk about the key-thing that revived the .NET world in recent years and made it awesome. .NET Core How many of you have are using .NET Core? This talk is an introductory level talk where I'm going to start the very basic and share some the things I learned along the way https://github.com/dotnet/swag
  • #4: My name is tamir dresher Im an architect from codevalue israel and a software engineering lecturer at the ruppin academic center CodeValue is a consulting company and we are also the proud development center of OzCode the amazing debugging extension for visual studio. We have a booth here at conference, so please go and check it out, youll be amazed how you lived without it. My book Rx in action is now available at Manning early access program should be published in the next few months. And that the end of my self promotion(it never hurts right?). So what are we really here for?
  • #8: FCL – Framework Class Library
  • #10: On Mac OS you could check .net core version by using below command. ls /usr/local/share/dotnet/shared/Microsoft.NETCore.App/On Ubuntu: ls /usr/share/dotnet/shared/Microsoft.NETCore.App/
  • #11: FCL – Framework Class Library https://github.com/dotnet/docs/blob/master/docs/core/tutorials/netcore-hosting.md C:\Program Files\dotnet\dotnet.exe, app: C:\Program Files\dotnet\sdk\2.1.300-preview1-008174\MSBuild.dll
  • #12: SET COREHOST_TRACE=1
  • #13: var osNameAndVersion = System.Runtime.InteropServices.RuntimeInformation.OSDescription
  • #23: intersection
  • #27: https://github.com/dotnet/standard/blob/master/docs/versions.md
  • #28: additive https://github.com/dotnet/standard/blob/master/docs/versions.md