Upgrading to dotnet core 2.1.4 on Ubuntu 16.04

I don't get much time to play with linux or asp.net core any more. It's over a year since I've had a chance to play, since I got involved with a new startup last December. In fact, I have been so busy, I actually ended up turned off my ubuntu 16.04 server because it was was so long since I logged in.

So, I was delighted to block off a day today and find out what's changed.

I was on the latest version last time I checked. That's over a year ago. The LTS was at 1.0.4 back then. Since then we have bumped a whole major version number.

micheal@Ubuntu16:~$ dotnet -v  
.NET Command Line Tools (1.0.4)

I started off with the Prerequisites for .NET Core on Linux just to get up to speed.

I'm going ahead with upgrading directly to .NET Core 2.x

First, Setup the package manager.

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg  
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'  
sudo apt-get update

Next, Install .NET Core 2.x

sudo apt-get install dotnet-sdk-2.1.4  
micheal@Ubuntu16:~$ dotnet --version  

As of today we are on 2.1.4 according to the download page (the docs say 2.1.3).

A few notes from the Install info.

So, what's new in dotnet core 2.1.4?

  • dotnet restore is now implicit.
  • Retargeting to .NET Core 2.0
  • Now supports Visual Basic.
  • Support for C# 7.1
  • ... and a few more bits n bobs

Implicit support for dotnet restore

Well, It was only a matter of time before this happened.

Retargetting to .NET Core 2.0

My understanding is that one of the core reasons (lol, see what I did there ;-) for the major number bump was to align with the new .NET Standard 2.0. If you are one of the few people that didn't get the memo from David, .NET Standard is just a spec for a set of interfaces that tells us what surface is covered by each of the version of .net on the different platforms such as Mono, Xamarin, .NET Framework 4.6.1 If you want the greatest level of surface coverage, you should probably target the .NET Standard 2.0 where you can.

If you want to just target .NET Core 2.0 you would use the netcoreapp2.0 moniker.


If you want to target .NET Standard and get extra coverage on Mono, Xamarin and .NET Framework, you would use the netstandard2.0 moniker.


Support for Visual Basic

C#, F# and Visual Basic. Visual Basic? Does that still exist. Wow! Here is what you need to do to get started with vb support.

dotnet new console -lang vb  

That's so hilarous, I'm going to try it out.

Imports System

Module Program  
    Sub Main(args As String())
        Console.WriteLine("Hello World!")
    End Sub
End Module  

Yuck! That's probably the first and last time I use that command!

Support for C# 7.1

At this time, the main advantage is when you write those little throw away console apps that call await mymethod() and it all falls over because Main is not async. Well not any more!

Check this out.

static async Task<int> Main()  
    // do stuff
    return await DoAsyncWork();

That's about it.

Hello World in .NET Core 2.1.4

There are a few more templates in the latest version:

dotnet new --help  
Templates                                         Short Name       Language          Tags  
Console Application                               console          [C#], F#, VB      Common/Console  
Class library                                     classlib         [C#], F#, VB      Common/Library  
Unit Test Project                                 mstest           [C#], F#, VB      Test/MSTest  
xUnit Test Project                                xunit            [C#], F#, VB      Test/xUnit  
ASP.NET Core Empty                                web              [C#], F#          Web/Empty  
ASP.NET Core Web App (Model-View-Controller)      mvc              [C#], F#          Web/MVC  
ASP.NET Core Web App                              razor            [C#]              Web/MVC/Razor Pages  
ASP.NET Core with Angular                         angular          [C#]              Web/MVC/SPA  
ASP.NET Core with React.js                        react            [C#]              Web/MVC/SPA  
ASP.NET Core with React.js and Redux              reactredux       [C#]              Web/MVC/SPA  
ASP.NET Core Web API                              webapi           [C#], F#          Web/WebAPI  
global.json file                                  globaljson                         Config  
NuGet Config                                      nugetconfig                        Config  
Web Config                                        webconfig                          Config  
Solution File                                     sln                                Solution  
Razor Page                                        page                               Web/ASP.NET  
MVC ViewImports                                   viewimports                        Web/ASP.NET  
MVC ViewStart                                     viewstart                          Web/ASP.NET        

    dotnet new mvc --auth Individual
    dotnet new xunit 
    dotnet new --help

Just a few quick pointers. there is dotnet new razor and dotnet new page. The first creates a razor template project, or what Microsoft are now calling a ASP.NET Web App, and the latter creates just a single page which you can add to an existing project. The way you do this is to change to the Pages folder then issue the page command to add a new page and code behind page.

dotnet new razor  
cd Pages  
dotnet new page --name Foo  

Also, you may be disappointed that an Aurelia template is still not shipped with dotnet core, but I don't think it's going to happen going forward to be honest. Instead, there seems to be a preferred way of integrating Aurelia with ASP.NET core with the --here parameter to au and you can read more about that here.

The other feature that's new and that I like is the concept of metapackages. such as the Microsoft.AspNetCore.All packages that just packages up other packages which should make it easier going forward to upgrade sets of packages together.

So, Now that I have everything up to date, what do I want to build?

Well. that's a blog for another day.

Here is something to keep you guessing! :-)

reference architecture

comments powered by Disqus