Click here to Skip to main content
13,146,742 members (79,819 online)
Click here to Skip to main content
Add your own
alternative version

Stats

24.4K views
32 bookmarked
Posted 8 Sep 2016

Introduction to .NET Core 1.0

, 8 Sep 2016
Rate this:
Please Sign up or sign in to vote.
After working so many years with .NET Framework, now it’s time for .NET Core. What has changed and why it changed. Let’s understand it in this article.

Content

  • What is .NET Core
  • What is new about this framework?
  • Getting started with using .NET Core
  • Developing sample web application using CLI

What is .NET Core?

It is a new framework which was developed from scratch parallel to .NET 4.6 (Visual Studio 2015). Previously it was named as .NET 5.0. Because of this there was a confusion among developer, that this framework is a successor of .NET 4.6, but that was not the truth. It is totally a new framework built from scratch.

Image source: https://blogs.msdn.microsoft.com

As you can see that with this release of new framework, lots of new things got added such as CoreCLR & CoreFX replacing our traditional framework CLR & FCL which were bound to Windows platform.

CoreCLR basically includes the garbage collector, JIT compiler, base .NET data types and many low-level classes.

On top of .NET Core we have ASP.NET Core 1.0 and then ASP.NET Core MVC.

Lots of buzz which were going on in market regarding this framework and below is the result what we get J

What is new about this framework?

1) Cross platform

Image result for windows logo pngImage result for windows logo pngImage result for windows logo png

 

 

 

 

 

 

As we know, .NET framework runs only on Windows platform. But what about the developers working on other platform? They were using Mono Framework, which is an open source framework & was compatible with .NET Framework. This was not the product of Microsoft but they support this framework. With growing developers among different platforms it became must to make .NET Framework work with cross platform.

 

Developers of Windows were able to develop their application using the most powerful IDE i.e.- Visual Studio. But what about the Linux or Mac developers, they don’t have such IDE like visual studio. A good news with this framework is that, no more Visual Studio is needed for development. You can use any editor for development and can execute it using console.

To make it work on a cross platform, Microsoft build up a new set of runtime & libraries called as CoreCLR and CoreFX which they compiled for every platform and generated builds.

With making .Net Core a Cross Platrom, Microsoft removed the tightly IIS bound "System.Web"  and made it "Microsoft.AspNetCore" which will work for all platform hosting environment.

 

2) Open source

With the world moving towards open source, Microsoft made this framework totally an open source. Also the source code is available on GIT. You can now easily customize this framework according to your need.

3) Optimized .NET runtime & libraries



With this changes, Microsoft also made changes to its libraries which were available in our GAC on installation of .NET Framework.

One example I can think of is “System” library.

The “System” library consist of many logical libraries such as System.IO, System.Net, System.Configuration, etc. which get loaded into memory every time you use “System” library. But do you think there is a need to load the whole library when only a portion is needed. Suppose I need only System.IO then my project should only refer System.IO instead of System as a whole. To make it a light weight and optimized, .NET core now supports nugget packages for each of this logical library and they will no more refer from GAC (which was available only on Windows platform)

4) Introduction to CLI

.NET Core also introduces a Command line application called as dotnet.exe

This application will allow us to

  • create an application
  • execute the application
  • run the Intermediate language
  • host the CLR

for any platform.

5) Completely modular

Every time when there is any new feature added in any component of .NET framework, a new version was released by Microsoft. For eg – with ASP.NET MVC, there was a routing concept introduced till ASP.NET MVC 4 which was there in Visual Studio 2012 (.NET framework 4.5). But with ASP.NET MVC 5, they introduced something called as Attribute level routing which was added in Visual Studio 2013 (.NET Framework 4.5.1). This kind of changes in component may lead to introducing new release of framework version. But now that is all gone. With .NET Core, where everything is nugget package. It became very easy to upgrade the component as it will introduce the release of nugget package and not the whole framework. This makes everything modular.

6) Cloud ready environment

With .NET Core, we can build cloud based internet connected application like Web Apps, IOT apps & mobile backend.

Getting Started

Go to http://www.dot.net

Download & follow the installation steps of .NET Core for every platform.

This framework doesn’t come handy with visual studio by default. It is added as a separate installation and requires visual studio 2015 update 3 or you can download only separate .NET Core SDK. But in future version it could be integrated with Visual studio setup.

Developing Sample Web application using CLI

Prior to “dotnet” command line application, in .NET Core RC1 & ASP.NET Core RC1, we had dnx tool for developing & launching the application. This dnx tool consist of 3 pieces –

dnvm - Dotnet version manager – Installer to get dnx version

dnu – Dotnet utility - Tool for managing dependencies, building & publishing the application

dnx -Dotnet execution runtime – Used to execute the code.

But later these tool were integrated within the single .NET Core Command Line Application i.e. – dotnet

Let’s try to understand step by step how “dotnet” tool helps us to develop the app.

Initial Setup

Once installation of .NET Core is done, test it using opening command prompt and typing dotnet

Step 1- Open command prompt and go to directory where you want to keep your project related files.

Step 2- Type command

For developing console application,

>dotnet new –lang C#

Explanation

  • new command is used to create project. By default it will add a Program.cs & project.json file
  • C# specifies the programming language to be used. (Other option available is F#. VB is not yet available)

For developing web application,

>dotnet new –lang C# -t web

Note: One point to remember, with .NET Core we can develop Console or web application. As of today, we cannot create windows application.

Output

The folder will contain all the files.

Step 3- I will not make any changes in code and will use command to add all the dependencies in the project.

>dotnet restore

This command will restore all the dependencies added in project.json file. i.e. – Unpack all the dependent libraries within the nugget package & restore.

This command then create a new file project.lock.json containing unpacked dependent library names and version

Step 5- Build the application using command

>dotnet build

Step 6: Run the application

>dotnet run

This command will host the server in console and provide us the port to run the application. We can now open our browser & type http://localhost:5000

And the website will start running.

Output

Step 7- Publish the code

>dotnet publish

This command will publish the web app

Conclusion

In this article, I tried to explain you what has changed with .NET Core & why it changed

In the next article, I will explain about ASP.NET Core MVC structural changes & added features. I hope you liked this small article. Please do comment whether it’s good or bad. Sharing is valuable no matter what. Thank you.

There is a nice video by Shivprasad koirala which explains you in details regarding .NET Core. Note: (Some portions in video are changed now so kindly check that in my article)

https://www.youtube.com/watch?v=mr7RZkK40bU

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Pradeep Shet
Team Leader
India India
I am having 8+ year of Experience in microsoft technology like Asp.Net, WCF, MVC, MSSQL, Silverlight, LINQ, Angular, Knockout, Design Pattern, DI, Oracle, HTML5, CSS3, SAAS, Bootstrap & jquery. I am good in Object Oriented Programming. I am also a MCTS certified.

You may also be interested in...

Comments and Discussions

 
QuestionNice Post Pin
kiran G19-Oct-16 19:38
memberkiran G19-Oct-16 19:38 
AnswerRe: Nice Post Pin
Pradeep Shet20-Oct-16 20:50
memberPradeep Shet20-Oct-16 20:50 
Questionwell done Pin
Hari Krishna Narukullapati21-Sep-16 12:02
professionalHari Krishna Narukullapati21-Sep-16 12:02 
AnswerRe: well done Pin
Pradeep Shet22-Sep-16 7:02
memberPradeep Shet22-Sep-16 7:02 
QuestionError on 'restore' Pin
rkb13-Sep-16 10:10
memberrkb13-Sep-16 10:10 
GeneralWell done. Pin
originalexadore13-Sep-16 2:09
memberoriginalexadore13-Sep-16 2:09 
GeneralRe: Well done. Pin
Pradeep Shet13-Sep-16 2:22
memberPradeep Shet13-Sep-16 2:22 
QuestionTotally confused! Pin
Thornik9-Sep-16 14:12
memberThornik9-Sep-16 14:12 
AnswerRe: Totally confused! Pin
Member 1226179410-Sep-16 20:57
memberMember 1226179410-Sep-16 20:57 
AnswerRe: Totally confused! Pin
Pradeep Shet13-Sep-16 2:21
memberPradeep Shet13-Sep-16 2:21 
GeneralRe: Totally confused! Pin
Thornik13-Sep-16 5:35
memberThornik13-Sep-16 5:35 
AnswerRe: Totally confused! Pin
2374119-Sep-16 17:59
member2374119-Sep-16 17:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170915.1 | Last Updated 8 Sep 2016
Article Copyright 2016 by Pradeep Shet
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid