In this chapter, we are going to learn about tools used to perform development tasks for .NET Core 2.0 on Windows and Linux operating systems. Also, we will learn how to set up Linux and virtualization using VirtualBox and Hyper-V. This chapter will cover how to install .NET Core 2.0 and tools for Windows and Linux (Ubuntu). We will learn about the virtual machine (VM) setup for Ubuntu and create your first simple .NET Core 2.0 running application code. We will configure the VM to manage your first application. The purpose of this chapter is to get a general idea of the required tools and how to install .NET core 2.0 SDK for Windows and Linux, and give you basic F# understanding.
This chapter will cover the following:
- Downloading the required tools for Windows and Linux
- Installing .NET Core 2.0 and tools (Windows)
- Setting up an Ubuntu Linux VM
- Installing .NET Core 2.0 and tools (Linux)
- Creating simple running code
- F# primer
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.
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.
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:
- 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.
- 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 VirtualBox
5.1.
It will open a page that has options onVirtualBox 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 onWindows hosts
. In a similar way, we can select different platforms. On clickingWindows hosts
, it will download the VirtualBox executableVirtualBox-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.
- 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.
- 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.
Now that we are done with the downloads, it's time to install. As seen in the last section on Windows, we have two options for development in Windows:
- Visual Studio 2017 version 15.3
- Visual Studio Code
Based on your choice, you can follow the appropriate installation steps.
Double-click on the executable file downloaded for Visual Studio 2017 version 15.3 in the earlier section. This will start the installation. C# comes by default in every Visual Studio installation, so there is nothing to do for C#. Visual Studio 2017 also comes with F# support in all its editions: Community, Professional, and Enterprise. F# is an optional component though. The installer includes it as a selectable workload, or you can select it manually in the Individual components
tab, under the Development activities
category. Select F# language support
:

Visual Studio 2017 version 15.3 comes with the .NET Core SDK. Select .NET Core cross-platform development
under Workloads
during the Visual Studio 2017 version 15.3 installation:

For other versions of Visual Studio, download the .NET Core 2.0 SDK from https://www.microsoft.com/net/download/core, or update Visual Studio to 2017 15.3 and select .NET Core cross-platform development
under Workloads
.
Install Visual Studio Code by double-clicking the Visual Studio Code setup executable from its download location. It's a simple installation for Windows. Once Visual Studio Code is installed, launch it. The following screenshot shows the user interface layout of Visual Studio Code. It follows the conventional editor style and displays files and folders you have access to on the left side and the code content in the editor on the right side. It can be roughly divided into seven sections, as shown in the following screenshot:

Let's discuss them:
- Menu bar: The standard menu bar for doing various operations in the editor, such as opening a file/folder, editing, viewing and installing extensions, changing themes, debugging, running and configuring tasks, and getting help.
- Activity bar: Groups the most commonly performed activities on the leftmost side of the editor. It lets the user switch between the views. It is customizable and lets the user choose the views to be displayed in the bar, by right-clicking on the bar and selecting/unselecting the views. The bar itself can be hidden in the same way. By default, it has five views, as shown in the following screenshot:

EXPLORER: This view lets your browse, open, and manage all the files and folders in your project. You can create, delete, and rename files and folders, as well as move files and folders from here. You can also open the files/folders in Terminal (Command Prompt in Windows) from here by right-clicking and selecting
Open in Command Prompt
. You can find the file/folder location as well from here.SEARCH: This view lets you search and replace globally across your open folder.
SOURCE CONTROL: This lets you work with Git source control by default.
DEBUG: This view displays the breakpoints, variables, and call stack for debugging.
EXTENSIONS: This is used to install and manage extensions in Visual Studio Code.
- Side bar: This contains the view selected from the activity bar.
- Command Palette: As stated earlier, Visual Studio Code is keyboard-centric, so anyone who loves using a keyboard is going to have a great time working on Visual Studio Code. The Ctrl + Shift + P key combination brings up what is called a Command Palette. We can access all the functionality of Visual Studio Code from here. To make effective use of Visual Studio Code, it is highly recommended that the reader makes himself/herself well versed with the commands from the help menu item links:

- Editor: The editor is where the content of the file is displayed and the user can edit it. Visual Studio Code provides a feature called Split Editor (open to the side in Linux). Go to the
View
menu in the menu bar and selectSplit Editor
(alternatively you can type the command Ctrl +\). This will create a new editor region, where you can edit a group of files. These regions are called editor groups. The open editors can also be seen in the Explorer view in the sidebar. Visual Studio Code allows up to three editor groups, designated asLEFT
,CENTER
, andRIGHT,
as shown in the following screenshot:

- Panels: Displays the
TERMINAL
,OUTPUT
,PROBLEMS
, andDEBUG CONSOLE
panes below the editor. To see it in action, go to theView
menu and click any of the menu items fromPROBLEMS
,OUTPUT
,DEBUG CONSOLE,
and TERMINAL. Alternatively, you can also press their corresponding commands. We will see more on panels when we write our first application. - Status Bar: Displays information about the opened project and files being edited, such as errors, warnings, current line and column number, encoding, and file type.
Now we are familiar with Visual Studio Code, its layout, and basic functionality.
Note
Go to the Help
menu and explore in detail the features that Visual Studio Code offers. The Interactive Playground
highlights a number of features in Visual Studio Code and also lets you interactively try them out. The Help
menu also has Documentation
, Introductory Videos
, Tips and Tricks
, which are very handy.
Remember, Visual Studio Code is an editor and therefore we need to add support for the language we want to work with through extensions. Visual Studio Code is very rich in extensions. For our example and for the purpose of learning .NET Core 2.0, we will install extensions for C# and F#, as we will be working with them.
Let's start with C#, as after a fresh install we do not have support for C# and hence there would be no IntelliSense to work with on the editor. To install C#, let's switch to
and search for Extension
ViewC#
. We will choose C# for Visual Studio Code (powered by OmniSharp),
as shown in the following screenshot:

Click Install
and then click on Reload
and Visual Studio Code will start supporting C# along with its IntelliSense.
Similarly, search F#
and Install it. We will be using the
Ionide-fsharp
extension, as shown in the following screenshot:

With Visual Studio Code, we need to install .NET Core SDK - 2.0.0
(x64)
also, as Visual Studio Code doesn't install it. Double-click on the executable of .NET Core 2.0 SDK to install it, as shown in the following screenshot:

And with this, we are done with the installation of our prerequisites for development on the Windows platform. Next, we will set up a Linux (Ubuntu) VM and perform the installation of prerequisites there. If you are using a Windows platform and do not wish to set up a Linux VM, the next section can be skipped.
Note
The Visual Studio Code user interface was developed on the Electron framework, which is an open source framework used to build cross-platform desktop applications with JavaScript, HTML, and CSS. The editor is powered by Microsoft's Monaco Editor and gets its intelligence from OmniSharp/Roslyn and TypeScript. As all of these are open source, you can search them and see the source code in GitHub.