.NET Standard 2.0 Cookbook
eBook - ePub

.NET Standard 2.0 Cookbook

Develop high quality, fast and portable applications by leveraging the power of .NET Standard Library

Fiqri Ismail

Share book
  1. 394 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

.NET Standard 2.0 Cookbook

Develop high quality, fast and portable applications by leveraging the power of .NET Standard Library

Fiqri Ismail

Book details
Book preview
Table of contents
Citations

About This Book

Get the most out of.NET framework using standard libraries and create a.NET Standard 2.0 library from scratchAbout 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.NETWho This Book Is ForThis 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 libraryIn DetailThe.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 approachA 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

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is .NET Standard 2.0 Cookbook an online PDF/ePUB?
Yes, you can access .NET Standard 2.0 Cookbook by Fiqri Ismail in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in C#. We have over one million books available in our catalogue for you to explore.

Information

Year
2018
ISBN
9781788838726
Edition
1

Working with Files

In this chapter, we will be looking at these recipes:
  • Setting up .NET Core in Ubuntu
  • Creating a log as text
  • Creating an ASP.NET Core application in Ubuntu to use the library
  • Setting up .NET Core in macOS
  • Reading from a comma separated (CSV) text file
  • Creating a .NET Core console application in macOS to use the library
  • Compressing? Why not?
  • Creating a classic Windows application to use the library
  • Encrypting and Decrypting content in a text file
  • Creating a classic Windows application to use the library

Technical requirements

Readers should have a basic knowledge of C#. They should also have a basic knowledge of using Visual Studio, installing packages using NuGet, and referencing libraries within projects from other projects.
The code files for this chapter can be found on GitHub:
https://github.com/PacktPublishing/DotNET-Standard-2-Cookbook/tree/master/Chapter03
Check out the following video to see the code in action:
https://goo.gl/82FCEP

Introduction

As a developer, at some point, we will have to write some data to the disk or read data from the disk. This may be a simple text file, or may be a log file in a system you have written. .NET Framework offers great support for working with files. Mainly, we will be looking at the System.IO namespace and its usage of it.
In this chapter, we will be looking at some cross-platform applications as well. Each recipe will go through setting up new environments, such as Ubuntu and macOS, as well as building a .NET Standard 2.0 library and an accompanying application that uses the library.

Setting up .NET Core in Ubuntu

In this recipe, we will be going through how to set up .NET Core 2.x in an Ubuntu system. Ubuntu is a widely used Debian-based Linux environment. By visiting https://www.ubuntu.com/desktop, you can easily download and install Ubuntu on your system. You may have to use a virtual PC to do this. There are two great free tools that you can use:
  1. VMWare Workstation Player for Windows: https://www.vmware.com/products/workstation-player.html
  2. Oracle Virtual Box for Windows, Linux, and macOS: https://www.virtualbox.org/wiki/Downloads
This chapter assumes you have already set up and installed the required operating systems.

Getting ready

You will have to download a virtual PC and install the latest version of Ubuntu. If you haven't got a virtual PC that runs Ubuntu, make sure you have before continuing this recipe done it yet. I am using Ubuntu version 16.04 here. To find out which version you have, simply type the following command in the terminal:
$ lsb_release -a
You should get the following output:

How to do it...

  1. Open your favorite browser, type the following URL, and press Enter:
    https://www.microsoft.com/net/download/linux
  1. Select the Install .NET Core SDK 2.x Package button.
  1. From the Linux Distribution drop-down list, select Ubuntu 16.04.
  1. Follow the instructions on the page to install the current SDK or perform the following steps to install.
  2. Now open the terminal, type the following command, and press Enter:
 $ curl https://packages.microsoft.com/keys/microsoft.asc | 
gpg --dearmor > microsoft.gpg
  1. If you have a fresh installation of Ubuntu you might not have curl installed. If not use the following command to install curl:
 $ sudo apt-get install curl 
  1. Now, again in the terminal type the following command and press Enter to get the list of files:
 $ sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
  1. Type the following command and press Enter in the terminal:
 $ sudo sh -c 'echo "deb [arch=amd64] 
https://packages.microsoft.com/repos/
micro...

Table of contents