Modern .NET Ecosystem
Andrei Marukovich
LunarFrog.com
twitter: @amarukovich
Agenda
• .NET Standard
• VS 2017 and .NET Core tooling
• Usage in practice
.NET ecosystem
.NET Framework .NET Core Xamarin
WPF
ASP.NET
WinForms UWP
ASP.NET Core
iOS
macOS
Android
Code sharing and library types
• Source file links
• Shared projects
• Portable class libraries (PCLs)
• .NET Standard
Shared projects
• Better version of the source file links
UWP project Xamarin project
File1.cs
File2.cs
SharedLib
File1.cs
File2.cs
SharedLib
File1.cs
File2.cs
SharedLibUI
App layer
UI
App layer
Portable class libraries
• Sharing code in binary form, without recompiling
UWP project Xamarin project
File1.cs
File2.cs
PortableLib
UI
App layer
UI
App layer
How it works?
• PCLs are based on profiles
• Profile defines an API surface supported by the library
• Profile is identified by combination of supported platforms
• http://embed.plnkr.co/03ck2dCtnJogBKHJ9EjY
• C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETPortable
UWP
Profile API surface
Xamarin
Android
.NET
Framework
.NET Standard
.NET Standard
• An evolution of PCLs, recommended approach for new libraries*
• Defines a set of APIs to be implemented by .NET platforms
(specification)
• Is versioned (API level)
• Version defines API surface, not supported frameworks
• The higher the version, the more APIs you have
• The lower the version, the more .NET platforms implement it
• Library developers may choose target .NET Standard version
.NET platform support
http://github.com/dotnet/standard
.NET Standard 2.0
Big picture
.NET Standard
• Current state
• Tooling is in preview
• Currently PCLs support a wider range of platforms
• At the moment, PCL adoption (# of libraries) is higher than .NET Standard
• Future
• PCL replacement
• Standard 2.0 will have significantly larger API surface
• Standard 2.0 will be interoperable with .NET Framework
Visual Studio 2017 demo
Recap
• .NET Standard is the future
• project.json is obsolete
• .csproj, msbuild and NuGet play nicely together
Additional information
• Additions to the csproj format for .NET Core
• https://docs.microsoft.com/en-us/dotnet/articles/core/tools/csproj
• NuGet pack and restore as MSBuild targets
• https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets
• How to use new features of MSBuild 15 with .NET Framework
projects
• http://lunarfrog.com/blog/how-to-use-msbuild15-net-framework
Thank you!
Andrei Marukovich
contact@lunarfrog.com
twitter: @amarukovich

Modern .NET Ecosystem

  • 1.
    Modern .NET Ecosystem AndreiMarukovich LunarFrog.com twitter: @amarukovich
  • 2.
    Agenda • .NET Standard •VS 2017 and .NET Core tooling • Usage in practice
  • 3.
    .NET ecosystem .NET Framework.NET Core Xamarin WPF ASP.NET WinForms UWP ASP.NET Core iOS macOS Android
  • 4.
    Code sharing andlibrary types • Source file links • Shared projects • Portable class libraries (PCLs) • .NET Standard
  • 5.
    Shared projects • Betterversion of the source file links UWP project Xamarin project File1.cs File2.cs SharedLib File1.cs File2.cs SharedLib File1.cs File2.cs SharedLibUI App layer UI App layer
  • 6.
    Portable class libraries •Sharing code in binary form, without recompiling UWP project Xamarin project File1.cs File2.cs PortableLib UI App layer UI App layer
  • 7.
    How it works? •PCLs are based on profiles • Profile defines an API surface supported by the library • Profile is identified by combination of supported platforms • http://embed.plnkr.co/03ck2dCtnJogBKHJ9EjY • C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETPortable
  • 8.
  • 9.
  • 10.
    .NET Standard • Anevolution of PCLs, recommended approach for new libraries* • Defines a set of APIs to be implemented by .NET platforms (specification) • Is versioned (API level) • Version defines API surface, not supported frameworks • The higher the version, the more APIs you have • The lower the version, the more .NET platforms implement it • Library developers may choose target .NET Standard version
  • 11.
  • 12.
  • 13.
  • 14.
    .NET Standard • Currentstate • Tooling is in preview • Currently PCLs support a wider range of platforms • At the moment, PCL adoption (# of libraries) is higher than .NET Standard • Future • PCL replacement • Standard 2.0 will have significantly larger API surface • Standard 2.0 will be interoperable with .NET Framework
  • 15.
  • 16.
    Recap • .NET Standardis the future • project.json is obsolete • .csproj, msbuild and NuGet play nicely together
  • 17.
    Additional information • Additionsto the csproj format for .NET Core • https://docs.microsoft.com/en-us/dotnet/articles/core/tools/csproj • NuGet pack and restore as MSBuild targets • https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets • How to use new features of MSBuild 15 with .NET Framework projects • http://lunarfrog.com/blog/how-to-use-msbuild15-net-framework
  • 18.

Editor's Notes

  • #6 Disadvantages Source-level sharing, no assembly Compiler directives Usability
  • #9 Disadvantages PCL’s require upfront decision on the supported platforms Lowest common denominator for the selected platforms Cannot use compiler directives Long term maintainability