NET Core, UWP, Nuget
Total Page:16
File Type:pdf, Size:1020Kb
.NET Core, UWP, NuGet INNOVATION 2.0 ■ .NET Core ■ .NET Standard ■ UWP ■ NuGet Packages ■ Future -> .NET Core 3 .NET Future how Microsoft sees it ■ Today ■ various tech stacks ■ Future ■ one Standard Library https://appdevelopermagazine.com/looking-at-the-future-of-.net/ School of Engineering © K. Rege, ZHAW 2 von 82 .NET Framework Evolution ■ The .NET Framework library has evolved Mono Project during the years ■ Goal: Run Microsoft .NET applications cross-platform ■ Better development tools to Linux developers. ■ Mono can be run on many platforms ■ Android, most Linux distributions, ■ BSD, macOS, Windows, Solaris, and even some game consoles such as PlayStation 3, Wii, and Xbox 360. ■ Current status 21. Dec 2018 ■ .NET 4.7.2 is supported .NET 1.NET 2 .NET School of Engineering © K. Rege, ZHAW 4 von 82 Xamarin ■ Xamarin is a Microsoft-owned San Francisco-based software company ■ Founded in May 2011 by the engineers that created Mono ■ Xamarin library is based on Mono ■ Xamarin.Forms using C# and XAML that is multi platform ■ Xamarin is a technology that allows to develop native apps for multiple platforms ■ Using a single C# codebase and .Net. ■ common code can be shared and reused, allowing to reduce the codebase . ■ Mono and the .Net Framework are not totally compatible to Xamarin ■ Microsoft has defined a cross platform ".Net Standard" (later) ■ but this .Net Standard does not provide a common UI library - yet School of Engineering © K. Rege, ZHAW 5 von 82 What about the UI ■ There is a different UI library on each platform ■ in the .Net Ecosystem and no standard one. ■ On Windows, we find WPF (Windows Presentation Foundation) and WinForms, ■ On Linux and macOS (and also Windows) we have GtkSharp. ■ Xamarin.Forms (XAML based) ■ iOS, Android, UWP and macOS School of Engineering © K. Rege, ZHAW 6 von 82 Class Library Variants VS 17 ■ Build new Class Library Project ■ .NET Standard ■ runs on any standard compatible framework ■ such as .NET Core, .NET Framework, Mono/Xamarin ■ + the number of Apps that will be compatible ■ - API surface area compatible to your library ■ .NET Framework ■ uses the full .NET 4.x Framework classes ■ .NET Core ■ uses the Core Framework classes ■ + increase the API surface area your library ■ - only .NET Core Apps are compatible ■ Legacy Portable ■ target a very specific subset of .NET implem. ■ strongly discourage their use in new application ■ Universal Windows ■ target a very UWP specific implem. Subset ■ + the number of Apps that will be compatible School of Engineering © K. Rege, ZHAW 7 von 82 School of Engineering © K. Rege, ZHAW 8 von 82 .NET Core ■ Is a new cross-platform Implementation of .NET Libraries ■ Elimination of windows only features (e.g. Registry, Forms, WPF) School of Engineering © K. Rege, ZHAW 9 von 82 Benefits of .NET Core ■ .NET Core (codename .NET vNext) ■ first introduced in 2014 ■ Open Source ■ The main benefits are: School of Engineering © K. Rege, ZHAW 10 von 82 … Benefits of .NET Core ■ Compatibility: ■ .NET Core: provides a portable subset of the .NET Framework ■ Class Libraries: CoreFX ■ smaller footprint than standard libraries ■ Performance and Scalability: ■ NET Core: enhance the performance and scalability due to wider platform support ■ Deployment Options: ■ .NET Framework: Internet Information Server only ■ .NET Core: directly in the cloud or self-host the application by creating own hosting process. ■ Framework -Dependent Deployment (FDD) ■ .NET Core SDK has to be installed on machine beforehand ■ Self-Contained Deployment (SCD) ■ .NET Core CLR and class library as part of application package School of Engineering © K. Rege, ZHAW 11 von 82 When to Use .NET Core ■ Use .NET Core for your server application when: ■ You have cross-platform needs. ■ You are targeting microservices. ■ You are using Docker containers. ■ You need high-performance and scalable systems. ■ You need side-by-side .NET versions per application. ■ Use .NET Framework for your server application when: ■ Your app currently uses .NET Framework (recommendation is to extend instead of migrating). ■ Your app uses third-party .NET libraries or NuGet packages not available for .NET Core. ■ Your app uses .NET technologies that aren't available for .NET Core. ■ e.g. Registry,Win Forms ■ Your app uses a platform that doesn’t support .NET Core. https://docs.microsoft.com/en-us/dotnet/standard/choosing-core-framework-server School of Engineering © K. Rege, ZHAW 12 von 82 .NET Framework vs .NET Core ■ Application Model ■ .NET Framework: Windows Forms, ASP.NET, and Windows Presentation Foundation (WPF). ■ .NET Core: ASP.NET Core and Windows Universal Apps. ■ .NET Standard: ■ formerly called "Unified BCL" ■ .NET Framework: Each version of .NET Framework uses a specific version ■ For instance, .NET Framework 4.6 implemented the .NET Standard Library 1.3 ■ NET Core 1.0 implements Standard Version 1.6 ■ ASP.NET: ■ .NET Core: is a complete rewrite of the existing ASP.NET Framework ■ To be highly modular, with a number of best practices built in (e.g. dependency injection). ■ No longer is there a web.config or global.asax, ■ In their place are startup.cs and project.json (among others). School of Engineering © K. Rege, ZHAW 13 von 82 RyuJIT Compiler ■ New JIT Compiler for version 2.0 ■ more efficient native machine code ■ is 100% faster than previous version ■ generated 30% faster code ■ supports X64 and X86 architectures ■ Profile guided optimization ■ records information about code execution ■ this information is used for optimize code generation ■ Similar to Java's Hotspot approach but separated optimization step School of Engineering © K. Rege, ZHAW 14 von 82 Core Microservices Architecture ■ Azure App Service ■ For stateless microservices. ■ -> Fowler GoTo 2014 Talk https://www.youtube.com/watch?v=wgdBVIX9ifA ■ Based on Docker ■ Can be hosted in your own Linux or Windows infrastructure, ■ A cloud service such as Azure Container Service. ■ Azure Service Fabric ■ for large and complex microservice systems ■ Azure Kubernetes Service (AKS) https://azure.microsoft.com/en-us/services/kubernetes-service/ https://docs.microsoft.com/en-us/azure/aks/ School of Engineering © K. Rege, ZHAW 15 von 82 Core Hello World School of Engineering © K. Rege, ZHAW 16 von 82 Hello World Application with VS ■ File > New > Project -> Console App (.NET Core) https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio School of Engineering © K. Rege, ZHAW 17 von 82 … Hello World Application Build and Run ■ Application template automatically defines a class, Program, with a single method, Main ■ To keep Console Window open add to generated main Method Console.Write("PressConsole.Write("Press anyany keykey toto continue...");continue..."); Console.ReadKey(true);Console.ReadKey(true); ■ And press start School of Engineering © K. Rege, ZHAW 18 von 82 Hello World Application with CLI ■ Simply start a new console and create a new directory, type > dotnet new console > dotnet run Hello World! <Project Sdk="Microsoft.NET.Sdk"> ■ Generated files: <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp2.1</TargetFramework> </PropertyGroup> </Project> using System; namespace temp { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } } School of Engineering © K. Rege, ZHAW 19 von 82 … DOTNET CLI commands ■ CLI command structure consists of ■ the driver ("dotnet"), ■ the command (or "verb"), ■ and possibly command arguments and options. ■ Example greate, build and run https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet?tabs=netcore21 School of Engineering © K. Rege, ZHAW 20 von 82 Development Environment ■ Visual Studio ■ By Microsoft ■ Supported on Windows and Mac: ■ Visual Studio provides an Integrated Development Environment (IDE) for Windows and macOS. ■ ReSharper from JetBrains ■ Rider ■ By JetBrains ■ Cross-platform .NET IDE based on the IntelliJ platform and ReSharper. ■ Visual Studio Code ■ By Microsoft but Open Source ■ Runs on Mac, Linux, and Windows ■ Based on Electron based on Chromium and Node.js ■ Integration via .NET Core command-line interface (CLI) tools ■ i.e. Notepad++ with memory footprint of VS ■ Works with any other Editors Notepad++, Sublime, Emacs, and Vi ■ Integration via .NET Core command-line interface (CLI) tools School of Engineering © K. Rege, ZHAW 21 von 82 Not Yet Available for .NET Core 2.2 ■ ASP.NET Web Forms applications ■ ASP.NET Web Pages applications ■ WPF and WinForms Applications ■ WCF Services Implementation ■ There’s a WCF-Client library to consume WCF services from .NET Core ■ Workflow-related services ■ Windows Workflow Foundation (WF), Workflow Services ■ ADO.NET Data Services ■ Blog: what should become part of .NET Core https://github.com/dotnet/corefx/issues?q=is%3Aopen+is%3Aissue+label%3Aport-to-core School of Engineering © K. Rege, ZHAW 22 von 82 .NET Standard School of Engineering © K. Rege, ZHAW 23 von 82 .NET Standard ■ Each .NET implementation version advertises the highest .NET Standard version it supports School of Engineering © K. Rege, ZHAW 24 von 82 UWP School of Engineering © K. Rege, ZHAW 25 von 82 The Convergence Journey School of Engineering © K. Rege, ZHAW 26 von 82 One Window Platform School of Engineering © K. Rege, ZHAW 27 von 82 Features of UWP Apps ■ Secure: ■ UWP apps declare which device resources and data they access. ■ The user must authorize that access. ■ Able to use a common API on all devices that run Windows 10. ■ Able to use device specific capabilities and adapt the UI to different device screen