O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

.NET Standard 2.0 Cookbook

Book Description

Get the most out of .NET framework using standard libraries and create a .NET Standard 2.0 library from scratch

About This Book
  • Write code once and share within .NET ecosystem in Windows, Linux and macOS
  • Give your .NET Libraries a common framework in cloud and on premise with the latest .NET Standard 2.0
  • Build a wide range of applications from Mobile with Xamarin to Web with ASP.NET
Who This Book Is For

This book is for .NET developers who are looking to build dynamic applications with the latest .NET Standard. C# knowledge is required.

What You Will Learn
  • Create a .NET Standard 2.0 library
  • Use System.IO within the .NET Standard 2.0
  • Make use of your legacy .NET libraries with the new .NET Core standard
  • Explore the thread support to create a multithreaded .NET Standard 2.0 library
  • Create a .NET Standard 2.0 library and use it with an Android and iOS application
  • Implement various Visual Studio 2017 diagnostics and debugging tools
  • Create a NuGet Package and submit the package to the NuGet Package Manager
  • Use Visual Studio 2017 azure tools to deploy the application to Azure
  • Test and deliver a .NET Standard 2.0 library
In Detail

The .NET Standard is a standard that represents a set of APIs that all .NET platforms have to implement, making it easy for developers to access and use one common library for their development needs. This book begins with a quick refresher, helping you understand the mechanics of the new standard and offering insight into how it works. You'll explore the core library concepts, such as working with collections, configurations, I/O, security, and multithreading. You'll explore the iOS and Android libraries of Xamarin and we'll guide you through creating a .NET Standard 2.0 library, which you'll use with both Android and iOS applications.

In the final chapters, you'll learn the various debugging and diagnostics tools to deliver quality libraries and create a NuGet package of the .NET Standard 2.0 library. By the end of this book, you'll be able to expand your current workflow to various .NET flavors and have the essential skills to create a .NET Standard 2.0 library from scratch to package and deliver it to the world.

Style and approach

A recipe-based approach to help you get the most out of the .NET Standard 2.0 Library that can be implemented to all the .NET Platforms

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. .NET Standard 2.0 Cookbook
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Code in Action
      3. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    5. Get in touch
      1. Reviews
  6. Back to Basics
    1. Technical requirements
    2. Introduction 
    3. Creating a C#-based console application
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Creating a C# class library 
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Creating a classic Windows-based application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Creating a WPF-based application to use the library 
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Hello Universe – My first .NET Standard class library
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Creating a Windows console-based application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Creating an ASP.NET Core-based web application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
  7. Primitives, Collections, LINQ, and More
    1. Technical requirements
    2. Introduction
    3. Building a .NET Standard 2.0 library that uses primitives
      1. Getting ready 
      2. How to do it...
      3. How it works...
    4. A .NET console application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Creating collections
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. A WPF application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Describing our library with Reflections
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. A .NET Core console application to use the library
      1. Getting ready 
      2. How to do it...
      3. How it works...
    9. Building a .NET Standard 2.0 library that uses LINQ
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. An ASP.NET MVC application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
  8. Working with Files
    1. Technical requirements
    2. Introduction
    3. Setting up .NET Core in Ubuntu
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating a log as text
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Creating an ASP.NET Core application in Ubuntu to use the library
      1. Getting ready
      2. How to do it..
      3. How it works...
    6. Setting up .NET Core in macOS
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Reading from a comma separated (CSV) text file
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Creating a .NET Core console application in macOS to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Compressing? Why not?
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Creating a classic Windows application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    11. Encrypting and decrypting content in a text file
      1. Getting ready
      2. How to do it...
      3. How it works...
    12. Creating a classic Windows application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
  9. Functional Programming
    1. Technical requirements
    2. Introduction
    3. Creating a .NET Standard 2.0 library
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating a .NET Core console application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Creating a .NET Standard 2.0 library that uses tuples
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Creating a Razor Pages web application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Creating a .NET Standard 2.0 library that uses delegates and lambda expressions
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Creating a .NET console application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
  10. XML and Data
    1. Technical requirements
    2. Introduction
    3. Creating a library that reads and writes to an XML file
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating an ASP.NET MVC application to use the XMLLib library
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Processing an XML file using LINQ to XML
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Creating a .NET Core console application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
  11. Exploring Threading
    1. Technical requirements
    2. Introduction
    3. Creating a library that can perform several things at once
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating a .NET Core console application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Creating an async method with tasks
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Creating a WPF application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Creating a thread pool
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Creating a .NET console application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
  12. Networking
    1. Technical requirements
    2. Introduction
    3. A library that displays an IP address and the name using sockets
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating a classic Windows application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Creating a library that sends mail
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Creating a WPF application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Creating a library to call a REST API
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Creating an ASP.NET MVC application to use the library
      1. Getting ready
      2. How to do it..
      3. How it works...
  13. To iOS with Xamarin
    1. Technical requirements
    2. Introduction
    3. Installing Visual Studio for Mac
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Hello iOS – Creating a Xamarin iOS app
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Creating the .NET Standard 2.0 library
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Putting things together and testing the application
      1. Getting ready
      2. How to do it...
      3. How it works...
  14. To Android with Xamarin
    1. Technical requirements
    2. Introduction
    3. Hello Android – Creating a Xamarin Android app
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Adding a .NET Standard 2.0 library to the Xamarin project
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Putting things together and testing the application
      1. Getting ready
      2. How to do it...
      3. How it works...
  15. Let’s Fine-Tune Our Library
    1. Technical requirements
    2. Introduction
    3. A library logs things itself
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating a .NET Core console application to use the library
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Informing the end user – Exception handling and error messages
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Using Visual Studio 2017 diagnostics and debugging tools
      1. Getting ready
      2. How to do it...
      3. How it works...
  16. Packaging and Delivery
    1. Technical requirements
    2. Introduction
    3. Creating a .NET Standard 2.0 library
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating a NuGet package of your library
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Submitting the package to NuGet package manager
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Creating a classic Windows application and testing the NuGet package
      1. Getting ready
      2. How to do it...
      3. How it works...
  17. Deploying
    1. Technical requirements
    2. Introduction
    3. Creating a free Azure Cloud subscription
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating an ASP.NET core web application to use the library from NuGet
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Deploying the application to Azure Cloud
      1. Getting ready
      2. How to do it...
      3. How it works...