SlideShare a Scribd company logo
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Adopting NET Core
in mainstream projects
Raffaele Rialdi
@raffaeler
raffaeler@vevy.com
https://www.linkedin.com/in/raffaelerialdi/
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Many thanks to our sponsors & partners!
GOLD
SILVER
PARTNERS
PLATINUM
POWERED BY
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Who am I?
• I am Raffaele Rialdi, Senior Software Architect in Vevy Europe – Italy
• I am also consultant in many industries
– manufacturing, racing, healthcare, financial, …
• But also Speaker in italian and international conferences
– Trainer as well
• And very proud to have been awarded as a Microsoft MVP
– Since 2003
@raffaeler
raffaeler@vevy.com
github.com/raffaeler
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
ONE YEAR OF NETCORE LOVE …
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• It is a brand new CLR called CLRCore
– Code and libraries are open source on GitHub
• It runs cross-platforms (Windows, Linux and Mac)
– Also cross-devices (x86, x64, ARM)
• Targets the "server apps" (ASP.NET Core) and UWP
– No Winform, WPF or other UI-related set of classes
• Offers a powerful CLI
• Package-centric development lifecycle
– nuget is king
NetCore takeaways
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• Simplified version of the old csproj and live-editable
The new ".csproj" project format
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
<UserSecretsId>aspnet-aspnetcore20basic-2A96D10C-1768-4724-A51D-9B5C2ED7DC9A</UserSecretsId>
<DockerComposeProjectPath>..docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview1-final" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview1-final" />
</ItemGroup>
</Project>
The full csproj file for an ASP.NET Core MVC Application running on Docker
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• MVC/WebApi Apps
–ASP.NET Core is powerful and very fast
• Cross-platform web and console apps
–No ARM CPUs support
• Libraries based on netstandard
–They can be binary-shared across Frameworks
• It is also used on UWP and Xamarin
What should I use NetCore 1.x for?
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• A huge amount of new APIs  ~33'000 APIs
–More than twice compared to NetCore 1.0
• A single metapackage library
–Include the full ASP.NET Core stack
–If NetCore is pre-installed, deploying is super-small!
• Currently in Preview 1, RTM in Q3
What's coming with NetCore 2.0?
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
The ASP.NET Core Preview 1
Currently works only on NetCore
(and not on .NET Framework)
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• A library specification defining a set of APIs with no implementation
– Think to netstandard as it was a sort of huge interface
– All NET Frameworks must implement all those APIs
• CoreFX (the 'BCL' of NetCore) is a superset of netstandard
• Netstandard 2.0 libraries can reference .NET Framework 'old' libs
– A "compat shim" is provided to redirect the implementation to netstandard
– Only works if the same API is available on netstandard
– No recompile is needed, but once recompiled the shim is no longer needed
– About 70% of the current nuget published packages can be already used!
• Are you a library author? Make your library "netstandard" now!
What is netstandard?
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Current support for netstandard 1.0 to 1.6
Framework TFM
.NET Standard netstandard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0
.NET Core netcoreapp 1.0 1.0 1.0 1.0 1.0 1.0 1.0
.NET Framework net 4.5 4.5 4.5.1 4.6 4.6.1 4.6.2 vNext
Mono / Xamarin - 4.6 4.6 4.6 4.6 4.6 4.6 4.6
UWP uap 10.0 10.0 10.0 10.0 10.0 vNext vNext
Windows win 8.0 8.0 8.1
Windows Phone wpa 8.1 8.1 8.1
Silverlight wp 8.0
(obsolete frameworks)
more APIs
more Frameworks
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
netstandard 2.0 support (at the RTM time)
Framework TFM
.NET Standard netstandard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0
.NET Core netcoreapp 1.0 1.0 1.0 1.0 1.0 1.0 1.0 2.0
.NET Framework net 4.5 4.5 4.5.1 4.6 4.6.1 4.6.1 4.6.1 4.6.1
Mono / Xamarin - 4.6 4.6 4.6 4.6 4.6 4.6 4.6 vNext
UWP uap 10.0 10.0 10.0 10.0 10.0 vNext vNext vNext
Windows win 8.0 8.0 8.1
Windows Phone wpa 8.1 8.1 8.1
Silverlight wp 8.0
(obsolete frameworks)
more APIs
more Frameworks
Unity Game Framework is going to support netstandard 2.0
Version # of APIs
netstandard 1.6 13,501
netstandard 2.0 ~33 K
Delta +20 K
This table will be valid only when netstandard 2.0 will be shipped
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• Add Reference, MSDN said .... but ...
• The .NET 4.x project gets a dependency from:
– At least the System.Runtime.dll (the nuget one) version 4.1.0
• This version depends on the netstandard version you choose
– Other nuget packages (such as System.Reflection)
• But versions may be different ("original" vs nuget)
Using a netstandard library from a .NET project
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• App.Config is your best friend
–If an EXE explicitly reference the DLL referencing
nestandard
• You can use the DLL project app.config
• Or you can specify AutoBindingRedirect in the EXE csproj
–If it is dynamically loaded
• Pre-load System.Runtime using Assembly.LoadFrom
• Or intercept the load request with AssemblyResolve event
What if the dll nuget version is more recent?
<bindingRedirect
oldVersion="0.0.0.0-4.1.1.0"
newVersion="4.1.1.0" />
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• T4 templates are "evil"
– Dependencies can be resolved by referencing a DLL using the
mentioned solutions
– Pssst ... use Roslyn code generator instead!
• ETW EventRegister.exe forcibly load the original (wrong)
version in a secondary AppDomain (and fails)
– Extract the requested DLL from the nuget package and specify
this dll as a reference in the EventRegister options
• Code Generation
– Specify these additional dependencies
Edge cases in managing different versions
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Still complicated ...
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• Current Stable Release
– Full NetCore 1.x tooling / templates support
– Netstandard support
• Preview Release (Update 3 Preview)
– NetCore 1.x + 2.0 Preview 1 support
– Netstandard 2 support
– Live Unit Testing in .NET Core
– Multiple Framework support when debugging
• Preview releases live side-by-side and isolated
– Two setups, no messing up the installation, twice the size on the HDD ☺
Visual Studio 2017
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
One CLI for all the SDK versions
• The current (latest) version of the sdk
– dotnet --version
• Creating a new project
– dotnet new console  use the latest version
– dotnet new console --framework netcoreapp1.1
• Otherwise you can still force the version using global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.3"
}
}
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
API Cross-Reference
• A cross-reference with all .NET APIs
– Availability of every APIs in the .NET Framework, Mono, Net Core, …
• Answers to the question: which framework does support this API?
http://apisof.net
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• In VS2017 pick the "Publish" menu in the solution explorer
• The CLI can do it too:
dotnet publish –r ubuntu.14.04-arm –o folder –c Release
• The RID (Runtime Identifier) must be specified in the csproj
• The available RIDs are in the
Microsoft.NETCore.Platforms
package
Self-Contained Depolyment (SCD)
<RuntimeIdentifiers>win8-arm;ubuntu.14.04-arm;ubuntu.16.04-arm</RuntimeIdentifiers>
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• A NetCore app / library
– targets
– references Microsoft.NETCore.App
• A Netstandard library targets
– targets
– references NETStandard.Library
• Future 2.0 netcore apps
– targets
• Run on a specific framework version (this may change in the future)
How Projects specify the framework
<TargetFramework>netcoreapp1.1</TargetFramework>
<TargetFramework>netstandard1.4</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeFrameworkVersion>2.0.0-beta-001863-00</RuntimeFrameworkVersion>
 Never reference these metapackages in the nuget references
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Reducing the footprint of the SCD
• Replace netcoreapp1.1 with netstandard1.6
• Explicitly reference these base packages
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR" Version="1.0.2" />
<PackageReference Include="Microsoft.NETCore.DotNetHostPolicy" Version="1.0.1" />
</ItemGroup>
<TargetFramework>netstandard1.6</TargetFramework>
Standard templates Console WebApp
Default win10-x64 45.6 MB 55.5 MB
Default ubuntu.16.04-x64 52.6 MB 62.6 MB
Reduced win10-x64 28.5 MB 47.4 MB
Reduced ubuntu.16.04-x64 36.8 MB 55.9 MB
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Custom templates in a single slide
H:_demosTemplateDemo>dotnet new -i .
Templates Short Name Language Tags
----------------------------------------------------------------------------------------------
Console Application console [C#], F# Common/Console
Class library classlib [C#], F# Common/Library
Unit Test Project mstest [C#], F# Test/MSTest
xUnit Test Project xunit [C#], F# Test/xUnit
ASP.NET Core Empty web [C#] Web/Empty
ASP.NET Core Web App mvc [C#], F# Web/MVC
ASP.NET Core Web API webapi [C#] Web/WebAPI
A console app referencing Json.net library rafconsole Custom Templates
Solution File sln Solution
Examples:
dotnet new mvc --auth None --framework netcoreapp1.1
dotnet new rafconsole
dotnet new --help
Current folder
template.json
{
"author": "Raf",
"classifications": [ "Custom Templates" ],
"name": "A console app referencing Json.net library",
"identity": "RafConsole.RafConsoleTemplate.CSharp",
"shortName": "rafconsole",
"guids": [ "0AB14D86-C56C-4702-907F-C5F3C4E0031C" ],
"sourceName": "RafConsoleTemplate"
}
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• Interoperability with Node.JS
–Come to my session tomorrow, May 25 - 10:30
–Use your C# libraries from Node.JS
• Warning for the weak of heart
–The session also contains C++ code ☺
Tomorrow @ 10.30
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals

More Related Content

What's hot (20)

PDF
Provisioning Windows instances at scale on Azure, AWS and OpenStack - Adrian ...
ITCamp
 
PDF
The best of Windows Server 2016 - Thomas Maurer
ITCamp
 
PDF
Everyone Loves Docker Containers Before They Understand Docker Containers - A...
ITCamp
 
PDF
How to secure and manage modern IT - Ondrej Vysek
ITCamp
 
PDF
Blockchain for mere mortals - understand the fundamentals and start building ...
ITCamp
 
PDF
Migrating to Continuous Delivery with TFS 2017 - Liviu Mandras-Iura
ITCamp
 
PDF
Windows 10 Creators Update: what’s on tap for business users - Ionut Balan
ITCamp
 
PDF
From Developer to Data Scientist - Gaines Kergosien
ITCamp
 
PPTX
Serverless Single Page Apps with React and Redux at ItCamp 2017
Melania Andrisan (Danciu)
 
PDF
Modern cybersecurity threats, and shiny new tools to help deal with them - T...
ITCamp
 
PDF
Testing your PowerShell code with Pester - Florin Loghiade
ITCamp
 
PDF
Building and Managing your Virtual Datacenter using PowerShell DSC - Florin L...
ITCamp
 
PDF
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
ITCamp
 
PDF
Developing PowerShell Tools - Razvan Rusu
ITCamp
 
PDF
BUILD with Microsoft - Radu Stefan
ITCamp
 
PDF
The Microsoft Cloud and Server Strategy - Ben Armstrong
ITCamp
 
PDF
#NoAgile - Dan Suciu
ITCamp
 
PDF
What's New in Hyper-V 2016 - Thomas Maurer
ITCamp
 
PDF
Nano Server - the future of Windows Server - Thomas Maurer
ITCamp
 
PDF
Scaling face recognition with big data - Bogdan Bocse
ITCamp
 
Provisioning Windows instances at scale on Azure, AWS and OpenStack - Adrian ...
ITCamp
 
The best of Windows Server 2016 - Thomas Maurer
ITCamp
 
Everyone Loves Docker Containers Before They Understand Docker Containers - A...
ITCamp
 
How to secure and manage modern IT - Ondrej Vysek
ITCamp
 
Blockchain for mere mortals - understand the fundamentals and start building ...
ITCamp
 
Migrating to Continuous Delivery with TFS 2017 - Liviu Mandras-Iura
ITCamp
 
Windows 10 Creators Update: what’s on tap for business users - Ionut Balan
ITCamp
 
From Developer to Data Scientist - Gaines Kergosien
ITCamp
 
Serverless Single Page Apps with React and Redux at ItCamp 2017
Melania Andrisan (Danciu)
 
Modern cybersecurity threats, and shiny new tools to help deal with them - T...
ITCamp
 
Testing your PowerShell code with Pester - Florin Loghiade
ITCamp
 
Building and Managing your Virtual Datacenter using PowerShell DSC - Florin L...
ITCamp
 
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
ITCamp
 
Developing PowerShell Tools - Razvan Rusu
ITCamp
 
BUILD with Microsoft - Radu Stefan
ITCamp
 
The Microsoft Cloud and Server Strategy - Ben Armstrong
ITCamp
 
#NoAgile - Dan Suciu
ITCamp
 
What's New in Hyper-V 2016 - Thomas Maurer
ITCamp
 
Nano Server - the future of Windows Server - Thomas Maurer
ITCamp
 
Scaling face recognition with big data - Bogdan Bocse
ITCamp
 

Viewers also liked (10)

PPTX
ITCamp 2017 - Ciprian Sorlea - Fostering Heroes
ITCamp
 
PDF
Storage Spaces Direct - the new Microsoft SDS star - Carsten Rachfahl
ITCamp
 
PDF
7 Habits of Highly Paid Developers - Gaines Kergosien
ITCamp
 
PDF
Assembly of Japanese bicycle requires peace of mind - Peter Leeson
ITCamp
 
PDF
Strategies for securing your banks & enterprises (from someone who robs bank...
ITCamp
 
PDF
How to Start-up a Start-up - Mihail Rotenberg
ITCamp
 
PDF
Great all this new stuff, but how do I convince my management - Erwin Derksen
ITCamp
 
PDF
The Secret of Engaging Presentations - Boris Hristov
ITCamp
 
PPTX
One Azure Monitor to Rule Them All? (IT Camp 2017, Cluj, RO)
Marius Zaharia
 
PDF
ITCamp 2017 - Florin Coros - Decide between In-Process or Inter-Processes Com...
ITCamp
 
ITCamp 2017 - Ciprian Sorlea - Fostering Heroes
ITCamp
 
Storage Spaces Direct - the new Microsoft SDS star - Carsten Rachfahl
ITCamp
 
7 Habits of Highly Paid Developers - Gaines Kergosien
ITCamp
 
Assembly of Japanese bicycle requires peace of mind - Peter Leeson
ITCamp
 
Strategies for securing your banks & enterprises (from someone who robs bank...
ITCamp
 
How to Start-up a Start-up - Mihail Rotenberg
ITCamp
 
Great all this new stuff, but how do I convince my management - Erwin Derksen
ITCamp
 
The Secret of Engaging Presentations - Boris Hristov
ITCamp
 
One Azure Monitor to Rule Them All? (IT Camp 2017, Cluj, RO)
Marius Zaharia
 
ITCamp 2017 - Florin Coros - Decide between In-Process or Inter-Processes Com...
ITCamp
 
Ad

Similar to ITCamp 2017 - Raffaele Rialdi - Adopting .NET Core in Mainstream Projects (20)

PDF
Raffaele Rialdi
CodeFest
 
PDF
.NET Core Blimey! (Shropshire Devs Mar 2016)
citizenmatt
 
PDF
.NET Core Blimey! Windows Platform User Group, Manchester
citizenmatt
 
PDF
Introduction to dot net
QIANG XU
 
PPTX
.NET MeetUp Amsterdam 2017 - .NET Standard -- Karel Zikmund
Karel Zikmund
 
PPTX
.NET MeetUp Prague 2017 - .NET Standard -- Karel Zikmund
Karel Zikmund
 
PDF
.NET Core Blimey! (dotnetsheff Jan 2016)
citizenmatt
 
PPTX
What should you know about Net Core?
Damir Dobric
 
PPTX
Whats new in .net for 2019
Rory Preddy
 
PDF
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
citizenmatt
 
PPTX
Key Steps in Developing .NET Core Applications
Damir Dobric
 
PDF
.Net Core Blimey! (16/07/2015)
citizenmatt
 
PPTX
Overview of the new .NET Core and .NET Platform Standard
Alex Thissen
 
PDF
.net Core Blimey - Smart Devs UG
citizenmatt
 
PDF
.NET Core, ASP.NET Core Course, Session 1
Amin Mesbahi
 
PPTX
Net core
Damir Dobric
 
PPTX
The ultimate cheat sheet on .net core, .net framework, and .net standard
Concetto Labs
 
PPTX
.NET & C# Updates Fall 2019
Marco Parenzan
 
PDF
.Net framework vs .net core a complete comparison
Katy Slemon
 
PPTX
.NET Overview & Roadmap
Microsoft Tech Community
 
Raffaele Rialdi
CodeFest
 
.NET Core Blimey! (Shropshire Devs Mar 2016)
citizenmatt
 
.NET Core Blimey! Windows Platform User Group, Manchester
citizenmatt
 
Introduction to dot net
QIANG XU
 
.NET MeetUp Amsterdam 2017 - .NET Standard -- Karel Zikmund
Karel Zikmund
 
.NET MeetUp Prague 2017 - .NET Standard -- Karel Zikmund
Karel Zikmund
 
.NET Core Blimey! (dotnetsheff Jan 2016)
citizenmatt
 
What should you know about Net Core?
Damir Dobric
 
Whats new in .net for 2019
Rory Preddy
 
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
citizenmatt
 
Key Steps in Developing .NET Core Applications
Damir Dobric
 
.Net Core Blimey! (16/07/2015)
citizenmatt
 
Overview of the new .NET Core and .NET Platform Standard
Alex Thissen
 
.net Core Blimey - Smart Devs UG
citizenmatt
 
.NET Core, ASP.NET Core Course, Session 1
Amin Mesbahi
 
Net core
Damir Dobric
 
The ultimate cheat sheet on .net core, .net framework, and .net standard
Concetto Labs
 
.NET & C# Updates Fall 2019
Marco Parenzan
 
.Net framework vs .net core a complete comparison
Katy Slemon
 
.NET Overview & Roadmap
Microsoft Tech Community
 
Ad

More from ITCamp (20)

PDF
ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...
ITCamp
 
PDF
ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...
ITCamp
 
PDF
ITCamp 2019 - Peter Leeson - Managing Skills
ITCamp
 
PPTX
ITCamp 2019 - Mihai Tataran - Governing your Cloud Resources
ITCamp
 
PDF
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp
 
PDF
ITCamp 2019 - Florin Coros - Implementing Clean Architecture
ITCamp
 
PPTX
ITCamp 2019 - Florin Loghiade - Azure Kubernetes in Production - Field notes...
ITCamp
 
PPTX
ITCamp 2019 - Florin Flestea - How 3rd Level support experience influenced m...
ITCamp
 
PPTX
ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...
ITCamp
 
PPTX
ITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The Enterprise
ITCamp
 
PPTX
ITCamp 2019 - Cristiana Fernbach - Blockchain Legal Trends
ITCamp
 
PPTX
ITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data Lake
ITCamp
 
PPTX
ITCamp 2019 - Andy Cross - Business Outcomes from AI
ITCamp
 
PDF
ITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud Story
ITCamp
 
PDF
ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...
ITCamp
 
PPTX
ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...
ITCamp
 
PPTX
ITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go Now
ITCamp
 
PDF
ITCamp 2019 - Peter Leeson - Vitruvian Quality
ITCamp
 
PDF
ITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World Application
ITCamp
 
PDF
ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...
ITCamp
 
ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...
ITCamp
 
ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...
ITCamp
 
ITCamp 2019 - Peter Leeson - Managing Skills
ITCamp
 
ITCamp 2019 - Mihai Tataran - Governing your Cloud Resources
ITCamp
 
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp
 
ITCamp 2019 - Florin Coros - Implementing Clean Architecture
ITCamp
 
ITCamp 2019 - Florin Loghiade - Azure Kubernetes in Production - Field notes...
ITCamp
 
ITCamp 2019 - Florin Flestea - How 3rd Level support experience influenced m...
ITCamp
 
ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...
ITCamp
 
ITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The Enterprise
ITCamp
 
ITCamp 2019 - Cristiana Fernbach - Blockchain Legal Trends
ITCamp
 
ITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data Lake
ITCamp
 
ITCamp 2019 - Andy Cross - Business Outcomes from AI
ITCamp
 
ITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud Story
ITCamp
 
ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...
ITCamp
 
ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...
ITCamp
 
ITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go Now
ITCamp
 
ITCamp 2019 - Peter Leeson - Vitruvian Quality
ITCamp
 
ITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World Application
ITCamp
 
ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...
ITCamp
 

Recently uploaded (20)

PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 

ITCamp 2017 - Raffaele Rialdi - Adopting .NET Core in Mainstream Projects

  • 1. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Adopting NET Core in mainstream projects Raffaele Rialdi @raffaeler [email protected] https://www.linkedin.com/in/raffaelerialdi/
  • 2. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Many thanks to our sponsors & partners! GOLD SILVER PARTNERS PLATINUM POWERED BY
  • 3. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Who am I? • I am Raffaele Rialdi, Senior Software Architect in Vevy Europe – Italy • I am also consultant in many industries – manufacturing, racing, healthcare, financial, … • But also Speaker in italian and international conferences – Trainer as well • And very proud to have been awarded as a Microsoft MVP – Since 2003 @raffaeler [email protected] github.com/raffaeler
  • 4. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals ONE YEAR OF NETCORE LOVE …
  • 5. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • It is a brand new CLR called CLRCore – Code and libraries are open source on GitHub • It runs cross-platforms (Windows, Linux and Mac) – Also cross-devices (x86, x64, ARM) • Targets the "server apps" (ASP.NET Core) and UWP – No Winform, WPF or other UI-related set of classes • Offers a powerful CLI • Package-centric development lifecycle – nuget is king NetCore takeaways
  • 6. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • Simplified version of the old csproj and live-editable The new ".csproj" project format <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish> <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback> <UserSecretsId>aspnet-aspnetcore20basic-2A96D10C-1768-4724-A51D-9B5C2ED7DC9A</UserSecretsId> <DockerComposeProjectPath>..docker-compose.dcproj</DockerComposeProjectPath> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview1-final" /> </ItemGroup> <ItemGroup> <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview1-final" /> </ItemGroup> </Project> The full csproj file for an ASP.NET Core MVC Application running on Docker
  • 7. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • MVC/WebApi Apps –ASP.NET Core is powerful and very fast • Cross-platform web and console apps –No ARM CPUs support • Libraries based on netstandard –They can be binary-shared across Frameworks • It is also used on UWP and Xamarin What should I use NetCore 1.x for?
  • 8. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • A huge amount of new APIs  ~33'000 APIs –More than twice compared to NetCore 1.0 • A single metapackage library –Include the full ASP.NET Core stack –If NetCore is pre-installed, deploying is super-small! • Currently in Preview 1, RTM in Q3 What's coming with NetCore 2.0?
  • 9. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals The ASP.NET Core Preview 1 Currently works only on NetCore (and not on .NET Framework)
  • 10. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • A library specification defining a set of APIs with no implementation – Think to netstandard as it was a sort of huge interface – All NET Frameworks must implement all those APIs • CoreFX (the 'BCL' of NetCore) is a superset of netstandard • Netstandard 2.0 libraries can reference .NET Framework 'old' libs – A "compat shim" is provided to redirect the implementation to netstandard – Only works if the same API is available on netstandard – No recompile is needed, but once recompiled the shim is no longer needed – About 70% of the current nuget published packages can be already used! • Are you a library author? Make your library "netstandard" now! What is netstandard?
  • 11. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Current support for netstandard 1.0 to 1.6 Framework TFM .NET Standard netstandard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0 .NET Core netcoreapp 1.0 1.0 1.0 1.0 1.0 1.0 1.0 .NET Framework net 4.5 4.5 4.5.1 4.6 4.6.1 4.6.2 vNext Mono / Xamarin - 4.6 4.6 4.6 4.6 4.6 4.6 4.6 UWP uap 10.0 10.0 10.0 10.0 10.0 vNext vNext Windows win 8.0 8.0 8.1 Windows Phone wpa 8.1 8.1 8.1 Silverlight wp 8.0 (obsolete frameworks) more APIs more Frameworks
  • 12. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals netstandard 2.0 support (at the RTM time) Framework TFM .NET Standard netstandard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0 .NET Core netcoreapp 1.0 1.0 1.0 1.0 1.0 1.0 1.0 2.0 .NET Framework net 4.5 4.5 4.5.1 4.6 4.6.1 4.6.1 4.6.1 4.6.1 Mono / Xamarin - 4.6 4.6 4.6 4.6 4.6 4.6 4.6 vNext UWP uap 10.0 10.0 10.0 10.0 10.0 vNext vNext vNext Windows win 8.0 8.0 8.1 Windows Phone wpa 8.1 8.1 8.1 Silverlight wp 8.0 (obsolete frameworks) more APIs more Frameworks Unity Game Framework is going to support netstandard 2.0 Version # of APIs netstandard 1.6 13,501 netstandard 2.0 ~33 K Delta +20 K This table will be valid only when netstandard 2.0 will be shipped
  • 13. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • Add Reference, MSDN said .... but ... • The .NET 4.x project gets a dependency from: – At least the System.Runtime.dll (the nuget one) version 4.1.0 • This version depends on the netstandard version you choose – Other nuget packages (such as System.Reflection) • But versions may be different ("original" vs nuget) Using a netstandard library from a .NET project
  • 14. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • App.Config is your best friend –If an EXE explicitly reference the DLL referencing nestandard • You can use the DLL project app.config • Or you can specify AutoBindingRedirect in the EXE csproj –If it is dynamically loaded • Pre-load System.Runtime using Assembly.LoadFrom • Or intercept the load request with AssemblyResolve event What if the dll nuget version is more recent? <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
  • 15. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • T4 templates are "evil" – Dependencies can be resolved by referencing a DLL using the mentioned solutions – Pssst ... use Roslyn code generator instead! • ETW EventRegister.exe forcibly load the original (wrong) version in a secondary AppDomain (and fails) – Extract the requested DLL from the nuget package and specify this dll as a reference in the EventRegister options • Code Generation – Specify these additional dependencies Edge cases in managing different versions
  • 16. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Still complicated ...
  • 17. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • Current Stable Release – Full NetCore 1.x tooling / templates support – Netstandard support • Preview Release (Update 3 Preview) – NetCore 1.x + 2.0 Preview 1 support – Netstandard 2 support – Live Unit Testing in .NET Core – Multiple Framework support when debugging • Preview releases live side-by-side and isolated – Two setups, no messing up the installation, twice the size on the HDD ☺ Visual Studio 2017
  • 18. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals One CLI for all the SDK versions • The current (latest) version of the sdk – dotnet --version • Creating a new project – dotnet new console  use the latest version – dotnet new console --framework netcoreapp1.1 • Otherwise you can still force the version using global.json { "projects": [ "src", "test" ], "sdk": { "version": "1.0.3" } }
  • 19. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals API Cross-Reference • A cross-reference with all .NET APIs – Availability of every APIs in the .NET Framework, Mono, Net Core, … • Answers to the question: which framework does support this API? http://apisof.net
  • 20. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • In VS2017 pick the "Publish" menu in the solution explorer • The CLI can do it too: dotnet publish –r ubuntu.14.04-arm –o folder –c Release • The RID (Runtime Identifier) must be specified in the csproj • The available RIDs are in the Microsoft.NETCore.Platforms package Self-Contained Depolyment (SCD) <RuntimeIdentifiers>win8-arm;ubuntu.14.04-arm;ubuntu.16.04-arm</RuntimeIdentifiers>
  • 21. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • A NetCore app / library – targets – references Microsoft.NETCore.App • A Netstandard library targets – targets – references NETStandard.Library • Future 2.0 netcore apps – targets • Run on a specific framework version (this may change in the future) How Projects specify the framework <TargetFramework>netcoreapp1.1</TargetFramework> <TargetFramework>netstandard1.4</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework> <RuntimeFrameworkVersion>2.0.0-beta-001863-00</RuntimeFrameworkVersion>  Never reference these metapackages in the nuget references
  • 22. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Reducing the footprint of the SCD • Replace netcoreapp1.1 with netstandard1.6 • Explicitly reference these base packages <ItemGroup> <PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR" Version="1.0.2" /> <PackageReference Include="Microsoft.NETCore.DotNetHostPolicy" Version="1.0.1" /> </ItemGroup> <TargetFramework>netstandard1.6</TargetFramework> Standard templates Console WebApp Default win10-x64 45.6 MB 55.5 MB Default ubuntu.16.04-x64 52.6 MB 62.6 MB Reduced win10-x64 28.5 MB 47.4 MB Reduced ubuntu.16.04-x64 36.8 MB 55.9 MB
  • 23. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Custom templates in a single slide H:_demosTemplateDemo>dotnet new -i . Templates Short Name Language Tags ---------------------------------------------------------------------------------------------- Console Application console [C#], F# Common/Console Class library classlib [C#], F# Common/Library Unit Test Project mstest [C#], F# Test/MSTest xUnit Test Project xunit [C#], F# Test/xUnit ASP.NET Core Empty web [C#] Web/Empty ASP.NET Core Web App mvc [C#], F# Web/MVC ASP.NET Core Web API webapi [C#] Web/WebAPI A console app referencing Json.net library rafconsole Custom Templates Solution File sln Solution Examples: dotnet new mvc --auth None --framework netcoreapp1.1 dotnet new rafconsole dotnet new --help Current folder template.json { "author": "Raf", "classifications": [ "Custom Templates" ], "name": "A console app referencing Json.net library", "identity": "RafConsole.RafConsoleTemplate.CSharp", "shortName": "rafconsole", "guids": [ "0AB14D86-C56C-4702-907F-C5F3C4E0031C" ], "sourceName": "RafConsoleTemplate" }
  • 24. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • Interoperability with Node.JS –Come to my session tomorrow, May 25 - 10:30 –Use your C# libraries from Node.JS • Warning for the weak of heart –The session also contains C++ code ☺ Tomorrow @ 10.30