Introducing ASP.NET 5 on Ubuntu
ASP.NET 5 components
Following paragraphs describe some fundamental components of ASP.NET 5 (click here to go to demo part.):
.NET CLR is the new version of .NET, it has all the common features: ASP.NET 5, Web Forms, MVC, SignalR.
Core CRL is a subset of the .NET Core, which doesn’t depends on GAC, Registry and OS components. It’s designed for Web developers, infact it has only the ASP.NET 5 features; The intention with .NET 5 is that each application only imports and uses the libraries it needs.
DNX – .Net eXecution environment
DNX contains the components required to run an ASP.NET 5 application. It is described by ASP.NET Github wiki as an SDK containing everything needed to build and run an ASP.NET 5 applications. The DNX gives us the ability to cross compile a project across different renditions of a Common Language Runtime, and then execute on a specific variant of a CLR. We can compile against a .NET CLR, or a Core CLR, or both.
DNVM is the tool used to maintain, install, upgrade and set specific versions of DNX on the computer. As there can be multiple versions of DNX installed, DNVM is the tool used to assign a specific project to a specific DNX version. With DNVM, you can install a specific DNX version from the feed and set an alias for a specific version. You can also set the default version you want to work with on the computer.
The DNU library is located in the DNX folder, so this is version-specific to a DNX install. DNU is used to manage the packages required by an application to run. DNU is used to manage the dependencies in a .NET 5 application by installing or restoring the packages associated with a project (see project.json).
DEMO: Developing ASP.NET 5 on Ubuntu
The following demo shows how to install and develop applications using ASP.NET 5 on Ubuntu.
Setup Ubuntu OS
If you don’t already have an Ubuntu virtual machine, you can easily create it using Virtual Box or using an AWS free account, here’s the tutorial to setup a simple Ubuntu server + desktop environment on AWS.
Setup ASP.NET 5 and DNX
Install code editor
The new ASP.NET 5 frameworks tries to remove all the dependencies between ASP.NET and Visual studio IDE: you can choose you preferred code editor. Actually, I use Visual studio code: an open-source/cross-platform code editor powered by Microsoft.
To install Visual studio code on ubuntu, simply download it. When the download is completed extract the zip inside your home folder and type:
sudo ln -s /home/<your_username>/<vscode_folder>/Code /usr/local/bin/code
To run vs code inside a folder, type:
Scaffolding in ASP.NET 5
All ASP.NET 5 project templates can be generated using Yeoman: it helps you to kickstart new projects, prescribing best practices and tools to help you stay productive.
sudo npm install -g yo
sudo npm install -g generator-aspnet
Create and run ASP.NET 5 application
To create new project from template, type:
You can choose 8 different project templates, when you select an template, yeoman creates a new folder that contains all application file, to download all application packages and run the application, type:
dnx run, if the project is a console application,
dnx web if the project is a web application.
Here you can find an introduction to vNext keyfeatures.
Microsoft has learned that nowadays there isn’t a single dominant platform, developers need to write code that runs on multiple platforms and they should be comfortable writing apps using multiple code editors and IDE. All the future steps of ASP.NET developing process are visible on the official roadmap.