Getting Started With .NET Core On Visual Studio 2017

This post focuses on setting up .NET Core on Visual Studio 2017 and building a C# Hello World application with .NET Core.

What is .NET Core?

.NET core is an open source framework, which is released by Microsoft and maintained by .NET Community. Why do we need .NET Core rather than .NET? Here is the answer: Because .NET is a framework which runs only on Microsoft platform but .NET core is an open source framework and it is a cross-platform application development tool that supports Windows, Linux and Mac OS, which can be used in the Cloud, Internet of Things and some embedded devices.

 

Features of .Net Core

  • Deployment .NET Core is incorporated in your application or .NET Core is downloaded from the official site and installed in the client machine for local deployment.
  • Cross-Platform- It has the capability to run across all the platforms such as Windows, Mac OS and Linux.
  • Command-line tools- Using CLR, users and developers are able to demonstrate an application, using Command Line interface.
  • Open source- .NET Core is downloaded from the official site and GitHub because it is MIT and Apache 2 license.
  • Support .NET Core is released by Microsoft and it is maintained by .NET Community.
  • Compatible .NET Core is compatible with the existing .NET Framework, mono and Xamarin via .NET Standard library.

Release History of .NET Framework

The era of .NET started in 2002, which runs on Visual Studio .NET and the initial version is .NET 1.0 and the latest version of .NET is .NET Core 1.0, which released on 2016 and supports Visual Studio 2015 and Visual Studio 2017 RC. 
Road Map of ASP.NET Framework

 

Understanding .NET Core Execution

The image given below helps you to understand building and deployment of .NET Core Applications.

 
Distributions

The two major distributions of .NET Core are given below.

  • .Net Core- It includes existing .NET Core runtime and framework.
  • Current Version- .NET Core 1.0.
  • .NET Core SDK- It includes .NET Core and the .NET Core Tools.
  • Current version- .NET Core SDK 1.0 Preview 2.

How is this different to .NETCore?

.NET Core Framework supports Windows 8, Windows 8.1 and Universal Windows Platform Applications. For compatibility, moniker cannot be reused for “.NET Core Applications”.

What is a .NET Standard Application?

A .NET Application can run on any .NET Core runtime like Core CLR and .NET Native. It runs on Windows, Mac and Linux. .NET Core is an application, which builds the application packages, as it depends upon the application.

 

dotnet Commands

The list of commands are given below to create and deploy an application.

dotnet new

This command helps us to create a new C# Hello world Application.

 

dotnet restore

This command helps us to restore the dependencies for our configured project.

dotnet build

This command helps us to build an application.

 

dotnet run

This command helps us to run an application.

 

Before getting started the requirements given below are needed to build a hello world application, using Visual Studio 2017.

Microsoft Visual Studio 2017

Download and install Visual Studio 2017 from .NET Community installation guide. Click here.

 

Once download completes, start Visual Studio 2017 installation process. It may take some time to extract the dependencies to start Visual Studio 2017 installation process.

Make sure that you have installed .NET Core tools preview Workload - ".NET Core and Docker (Preview)". You can check and install the Workload by opening Visual Studio 2017 installation process.

 

Open up Visual Studio 2017 RC then click File -> New -> Project.

 

Now, a new project creation dialog appears in which you need to click .NET Core and then select .NET Core Console Application to create a simple hello world application.

 

Now, add the line given below to stay back in an output terminal.

  1. Console.ReadKey(true);

Now, press F5 to deploy an Application. Congrats, as our Application is deployed and the output is given, as shown below.

 

Enhancing Hello World Application

Now, add the code given below in Main function to make the changes.

  1. Console.WriteLine("\nWhat is your name? ");  
  2. var name = Console.ReadLine();  
  3. var date = DateTime.Now;  
  4. Console.WriteLine("\nHello, {0}, on {1:d} at {1:t}", name, date);  
  5. Console.Write("\nPress any key to exit...");  
  6. Console.ReadKey(true);  

Once changes are complete, click save button, deploy an Application and the output is given below.

 

Congrats, as we have successfully deployed an Application in Visual Studio 2017 using .NET Core.

Tools for Developers

 

Conclusion

In this article, we learned about setting up .NET Core in Visual Studio 2017 and deployed a simple hello world application. I hope you enjoyed reading this article. Thanks for reading.

Happy coding.

Up Next
    Ebook Download
    View all
    Learn
    View all