Skip to content

Create a .net core web application on ubuntu in 5 minutes

I have been spending the past few weeks getting familiar with .net core, the latest release of the .net framework from Microsoft.  I will be the first to admit that I am totally impressed by it and I am truly excited by this version of the framework.

The world I have been inhabiting over the past 4 or so years has been a world  of cross platform applications.  Typically developing applications which are designed or at leasts components of applications that are required to run on any mix of operating systems and platforms i.e. Windows. Mac and Linux and Web , Mobile and desktop.

I have always been fan of the .net framework and the Microsoft development tool stack in general but have not always been  a huge advocate of the  windows operating system.  In my  opinion it has always been so ironic that Microsoft have always created great development tooling but were always let down by the operating system.

Install .net core and VS Code

I installed the .net core and the super light weight development text editor called VS  Code, following the super easy to follow instructions on the Microsoft website. https://www.microsoft.com/net/core.

Create new web project using the terminal

It is really super easy to create a new web project using terminal window and open the new project in vscode afterward.

Shell

Running these simple commands will generate necessary boiler plate code required to start working on your next great project.

More templates

Although the above approach my generate you a template really quickly. The template itself is somewhat limiting and it pretty much based on the Microsoft MVC template, which is fine but if you would like work on more current technologies or would like to explore other options. There are alternate templates available.

The aspnet core team have made these templates available via the Yeoman generators, which will require the installation of yo and aspnet core yo generators.

You can install yo via the terminal if you have NPM (Node Package Manager ) . If not I recommend you install node using NVM (node version manager) on ubuntu.

Shell

We can now install the aspnet generators

Shell

Once complete we can now use it to generate our projects

Shell

Which will present the a screen and you can make your selection of the type of project you would like to create

Additional Single Page Application Templates

The community has been really busy creating some addtional project starter templates , which include using addtional frameworks like Aurelia etc. Check out Steve Sandersons blog for more information.

These templates are also available by making use of the Yeoman Generator, and are simple to install. However, before we install these templates there is one additional dependency we need to install called Webpack

Shell

We can now install the generators

Shell

Once installed we can generate a project using

Shell

Dotnet Core RC4 Templates

If you prefer make us of the dotnet new command to generate a project, you can but it will take an extra bit of configuration and you will need to install RC4 of the SDK tools

Shell

Once the install is complete, add the addtional templates

Shell

Once complete, you can then try dotnet new --help which then should display a list of new templates that are available.

Shell

With these new templates available you can then generate a new project using dotnet new [templatename] to generate a new project like

Shell

You can read more about these templates - Building Single Page Applications on ASP.NET Core with JavaScriptServices

Gary Woodfine
Latest posts by Gary Woodfine (see all)
Tags: