Book Image

.NET Core 2.0 By Example

By : Neha Shrivastava, Rishabh Verma
Book Image

.NET Core 2.0 By Example

By: Neha Shrivastava, Rishabh Verma

Overview of this book

With the rise in the number of tools and technologies available today, developers and architects are always exploring ways to create better and smarter solutions. Before, the differences between target platforms was a major roadblock, but that's not the case now. .NET Core 2.0 By Example will take you on an exciting journey to building better software. This book provides fresh and relevant content to .NET Core 2.0 in a succinct format that’s enjoyable to read. It also delivers concepts, along with the implications, design decisions, and potential pitfalls you might face when targeting Linux and Windows systems, in a logical and simple way. With the .NET framework at its center, the book comprises of five varied projects: a multiplayer Tic-tac-toe game; a real-time chat application, Let'sChat; a chatbot; a microservice-based buying-selling application; and a movie booking application. You will start each chapter with a high-level overview of the content, followed by the above example applications described in detail. By the end of each chapter, you will not only be proficient with the concepts, but you’ll also have created a tangible component in the application. By the end of the book, you will have built five solid projects using all the tools and support provided by the .NET Core 2.0 framework.
Table of Contents (16 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

Downloading required tools for Windows and Linux


In this section, we will discuss the prerequisites to be downloaded for both Windows and Linux operating systems to start development with .NET Core 2.0. We will start with Windows and then move to Linux. 

Downloads for Windows

Microsoft offers the Visual Studio integrated development environment (IDE) for developers to develop computer programs for Microsoft Windows, as well as websites, web applications, web services, and mobile applications. Microsoft gives us the choice to pick from four Visual Studio adaptations—Community, Professional, Enterprise, and Code. You can download one of these, depending on your individual prerequisite. How these versions differ from each other is explained next.

Navigate to https://www.visualstudio.com/downloads in the browser of your choice. You will see four choices. Select the Visual Studio product based on your requirements.

All versions of Visual Studio 2017 are available for Windows and Macintosh operating systems:

  • Visual Studio Community: This is a free, open source version of Visual Studio with limited features. This is for the individual developer. 
  • Visual Studio Professional: This version has professional developer tools, services, and subscription benefits for small teams (five members).
  • Visual Studio Enterprise: This version supports all Visual Studio features and is meant for end-to-end solution development to meet the demanding quality and scaling needs of teams of all sizes. It is great for enterprise organizations. Some of the key features that come with this version are testing tools, architectural layer diagrams, live dependency validation, architecture validation, code clone detection, IntelliTrace, .NET memory dump analysis, and so on.
  • Visual Studio Code: This is a free, open source version and cross-platform (Linux, macOS, Windows) editor that can be extended with plugins to meet your needs. It includes support for debugging, embedded Git control, syntax highlighting, extension support, intelligent code completion, snippets, and code refactoring.

Note

Make a note that Visual Studio is an IDE, while Visual Studio Code is an editor, just like Notepad is an editor. So Visual Studio Code is much more lightweight, fast, and fluid with great support for debugging and has embedded Git control. It is a cross-platform editor and supports Windows, Linux, and Macintosh. Debugging support is good and has rich IntelliSense and refactoring. Like most editors, it is keyboard-centric. It is a file and folders-based editor and doesn't need to know the project context, unlike an IDE. There is no File | New Project support in Visual Studio Code as you would be used to in Visual Studio IDE. Instead, Visual Studio Code offers a terminal, through which we can run dotnet command lines to create new projects.

So, for development in Windows, we can use either of these:

  • Visual Studio 2017 IDE
  • Visual Studio Code editor

If we choose Visual Studio 2017, all we need to do is download Visual Studio 2017 version 15.3 from https://www.visualstudio.com/downloads. It comes bundled with the .NET Core 2.0 SDK and its templates and so we will be ready for development immediately after installing it. Also with Visual Studio 2017, F# tools automatically get installed once we create an F# project or open an F# project for the very first time. So, the F# development setup is taken care of as well. We will see the installation of Visual Studio 2017 in the Installing .NET Core 2.0 and tools (Windows) section of this chapter.

If we choose Visual Studio Code for development, we need to download Visual Studio Code from https://code.visualstudio.com/download and the .NET Core 2.0.0 SDK from https://www.microsoft.com/net/core#windowscmd . We will look at the installation of Visual Studio Code in the Installing .NET Core 2.0 and tools (Windows) section of this chapter.

Downloads for Linux

As mentioned in the preceding section, Microsoft Visual Studio Code is a cross-platform editor, and it supports Linux operating systems. So, we are going to use Visual Studio Code to create all the example applications on Linux in this book.

Let's start downloading the tools required to stop our development of .NET Core 2.0 applications on the Linux operating system:

  1. Download Visual Studio Code from https://code.visualstudio.com/. We are going to install the Ubuntu 32-bit version, so we will download the Visual Studio Code 32-bit version. Select the Linux x86 .deb stable package for download, as shown in the following image:

If you have a Linux machine handy, you can skip the next download step. If you wish to try development on the Linux platform and have a Windows machine to work with, then the next two steps are for you.

  1. Download VirtualBox from https://www.virtualbox.org/. It is Oracle's open source general-purpose full virtualizer. At the time of writing this chapter, the latest version of VirtualBox is 5.1. The version 5.1.26 was released on July 27, 2017. Using this, we will set up a Linux (Ubuntu) virtual machine on the Windows host machine. Click on Download VirtualBox5.1. It will open a page that has options on VirtualBox binaries. We can select an option based on the machine on which we are installing it. We are installing it on a Windows machine, so we will click on Windows hosts. In a similar way, we can select different platforms. On clicking Windows hosts, it will download the VirtualBox executable VirtualBox-5.1.26-117224-Win.exe:

VirtualBox needs the Ubuntu International Standards Organization (ISO) image to create the Ubuntu VM, so next we need to download the ISO image of Ubuntu.

  1. Download the ISO image of Ubuntu by navigating to https://www.ubuntu.com. By default, the virtual machine software uses 32-bit Linux, so we will select 32-bit. Hover over the Downloads menu and click on the highlighted Desktop link:

It will take us to the downloads page for the desktop. Click Download on Ubuntu for the desktop. It will start the download of Ubuntu 17.04 ISO. An ISO image of approximately 1.5 GB will be downloaded.

  1. Download .NET Core 2.0 SDK from https://www.microsoft.com/net/download/linux

With this, we are done with the downloads for our setup in Linux. In the next section, we will learn how to install and set up these tools.

Note

Ubuntu 17.04: As of writing this chapter, this is the latest version, and its code name is Zesty Zapus, released on April 13, 2017. Ubuntu releases carry a version number in the form of XX.YY, with XX representing the year and YY representing the month of the official release. For example, the latest version released in April 2017 is represented by 17 (year) and 04 (month). Ubuntu code names use an adjective animal combination, that is an adjective word followed by the name of an animal, typically one that's unique. At the time of writing, Ubuntu 17.10 is due to be released in October 2017; examples covered here used the Ubuntu 17.04 version.